def returnHeaders(self): headers = { 'accept-language': 'en-US', 'x-forwarded-for': '172.0.01', 'accept': 'text/html', 'x-crawlera-cookies': 'disable', 'user-agent': str(RandomHeaders.returnUA()) } return headers
def SearchStore(store, SKU): a = {} a['Store'] = str(store) data = { 'authority': 'www.walmart.com', 'method': 'POST', 'path': '/store/ajax/search', 'scheme': 'https', 'accept': 'application/json, text/javascript, */*; q=0.01', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.8', 'content-length': '55', 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8', 'origin': 'https://www.walmart.com', 'referer': 'https://www.walmart.com/store/{}/search?query={}'.format(store, SKU), 'user-agent': str(RandomHeaders.returnUA()), 'x-requested-with': 'XMLHttpRequest', "searchQuery": "store={}&query={}".format(store, SKU), } url = "https://www.walmart.com/store/ajax/search" res = requests.post(url, data=data, proxies=random.choice(Proxies)) res = res.json() print res try: a["Price"] = int((GrabElement(str(res), 'priceInCents'))) except: pass a["Quantity"] = (GrabElement(str(res), 'quantity')) return a