#!/usr/bin/env python3 """Try all TradeTracker affiliate sites to find sneaker feeds.""" import requests import re SOAP_URL = 'https://ws.tradetracker.com/soap/affiliate' HEADERS = {'Content-Type': 'text/xml; charset=utf-8'} soap_auth = ''' 35058 bf0b9eef0da6caf55fe614518375280fe5c4ecca false nl_NL false ''' r = requests.post(SOAP_URL, data=soap_auth, headers={**HEADERS, 'SOAPAction': 'authenticate'}, timeout=15) cookies = r.cookies # Try Manify and Ladify sites which are fashion/sneaker related site_ids = [155885, 290654] # Manify, Ladify for site_id in site_ids: print(f'\n=== Site {site_id} ===') # Get campaigns soap = f''' {site_id} ''' r2 = requests.post(SOAP_URL, data=soap, headers={**HEADERS, 'SOAPAction': 'getCampaigns'}, cookies=cookies, timeout=30) campaigns = re.findall(r']*>(.*?)', r2.text, re.DOTALL) print(f'Campaigns: {len(campaigns)}') sneaker_campaigns = [] for c in campaigns: cid = re.search(r']*>(.*?)', c) name = re.search(r']*>(.*?)', c) if cid and name: cname = name.group(1) keywords = ['sneaker', 'schoen', 'shoe', 'sport', 'nike', 'adidas', 'puma', 'asics', 'foot', 'keep', 'mooie', 'outlet', 'fashion', 'kleding'] is_relevant = any(kw in cname.lower() for kw in keywords) if is_relevant: sneaker_campaigns.append((cid.group(1), cname)) print(f' *** [{cid.group(1)}] {cname}') else: print(f' [{cid.group(1)}] {cname}') # Get product feeds soap_pf = f''' {site_id} ''' r3 = requests.post(SOAP_URL, data=soap_pf, headers={**HEADERS, 'SOAPAction': 'getProductFeeds'}, cookies=cookies, timeout=30) feeds = re.findall(r']*>(.*?)', r3.text, re.DOTALL) print(f'Product feeds: {len(feeds)}') if r3.status_code != 200: print(f' Error: {r3.status_code} - {r3.text[:500]}') for f in feeds: fid = re.search(r']*>(.*?)', f) name = re.search(r']*>(.*?)', f) pcount = re.search(r']*>(.*?)', f) url_match = re.search(r']*>(.*?)', f) if fid and name: print(f' [{fid.group(1)}] {name.group(1)} [{pcount.group(1) if pcount else "?"} products]') if url_match: print(f' URL: {url_match.group(1)[:200]}')