import requests
from lxml import etree
import json
from urllib.parse import quote
url='https://search.kongfz.com/product_result/?'
params = {"key": "寻找家园 高尔泰",
"status": "0",
"_stpmt": "eyJzZWFyY2hfdHlwZSI6Imhpc3RvcnkifQ==",
"order": "100",
"exkey": "k5357k65b9",
"pagenum": "3",
"ajaxdata": "1",
"type": "1",
"_": "1633566309138",
}
headers={
"Accept": "application/json, text/javascript, */*; q=0.01",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Cookie": "randomcodekey=srck07063023927838ul5403; randomcode=192629802938; randomcodesign=A3GkVOK4B1YC44BF9B%2ByKIrWmLvWUaNjUw3rF4T3rZg1SWGfvSPGD4BEEjogH8B1teO3aSwuus4prtBjgqTMsQ%3D%3D; PHPSESSID=k6409tiif2fteisu67bjckjdkbcjdb43; shoppingCartSessionId=15ab707dd6aa2864b9fe9eb0888db25c; reciever_area=1006000000; utm_source=101002001000; kfz_uuid=15288efc-7f86-4a96-a115-b8d80480ec75; kfz_trace=15288efc-7f86-4a96-a115-b8d80480ec75|0|712770b3e94fc575|101002001000; TY_SESSION_ID=ebb7d64b-0476-486a-9ec4-53b1a21aadb8; kfz-tid=c0af3efccd3ddcd3eb23b237653a3b65; TINGYUN_DATA=%7B%22id%22%3A%22XMf0fX2k_0w%23nUhCMQN2SSk%22%2C%22n%22%3A%22WebAction%2FURI%2Fproduct%252Fsearch%252Fpc%252F%22%2C%22tid%22%3A%222a47a9378cce6c0%22%2C%22q%22%3A0%2C%22a%22%3A35%7D; acw_tc=276077bf16336059899317526e48646a016e9d56412ca95bf1dfeedf67baa5",
"Host": "search.kongfz.com",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
"Pragma": "no-cache",
"Referer": "https://search.kongfz.com/product_result/?key=%E5%AF%BB%E6%89%BE%E5%AE%B6%E5%9B%AD%20%E9%AB%98%E5%B0%94%E6%B3%B0&status=0&_stpmt=eyJzZWFyY2hfdHlwZSI6Imhpc3RvcnkifQ==&order=100&exkey=k5357k65b9&pagenum=3&ajaxdata=1",
"X-Requested-With": "XMLHttpRequest"
,
}
response=requests.get(url,params=params,headers=headers).json()
print(response)
返回内容 {'status': 0, 'data': [], 'message': 'invalid request', 'errType': 0, 'other': []}
正常XHR 内容这样