1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| url = "http://www.53iq.com/device/user/login" res = requests.get(url) s = res.headers['Set-Cookie'] s1 = re.findall(r'(sessionid=\S+)', s)[0] s2 = re.findall(r'(csrftoken=\S+)', s)[0]
payload = { 'csrfmiddlewaretoken': s2, 'username': 'XXX', 'password': 'XXXXXX' } cookie = s1 + ' ' + s2 + ' Hm_lvt_854b60cb774bd0cf1ab148e604cfd819=1471424118,1471575858,1471676503,1471687362; Hm_lpvt_854b60cb774bd0cf1ab148e604cfd819=1471687362' headers = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.8', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive', 'Content-Length': '87', 'Content-Type': 'application/x-www-form-urlencoded', 'Cookie': cookie, 'DNT': '1', 'Host': 'www.53iq.com', 'Origin': 'http://www.53iq.com', 'Pragma': 'no-cache', 'Referer': 'http://www.53iq.com/device/user/login', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36' } res = requests.post(url, data=payload, headers=headers)
headers = { 'Accept':'application/json, text/javascript, */*; q=0.01', 'Accept-Encoding':'gzip, deflate, sdch', 'Accept-Language':'zh-CN,zh;q=0.8', 'Cache-Control':'no-cache', 'Connection':'keep-alive', 'Cookie':cookie, 'DNT':'1', 'Host':'www.53iq.com', 'Pragma':'no-cache', 'Referer':'http://www.53iq.com/device/device/new_device', 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.366', 'X-Requested-With':'XMLHttpRequest' }
url = "http://www.53iq.com/device/device/get_new_device" params = { 'txtFaName': '海尔', 'page': '1', 'limit': '20' } res = requests.get(url, params=params, headers=headers)
print(res.json())
|