请问针对这种接口带有加密字段的该怎么获取数据,我通过cookies发送还是不行,是我的操作问题吗?
[Python] 纯文本查看 复制代码 import requests
def get_company_label_with_cookies_and_payload(url, cookies, payload):
# 构造请求头,包含cookies信息
headers = {
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'
}
# 发送 POST 请求并包含cookies信息和payload数据
response = requests.post(url, headers=headers, cookies=cookies, json=payload)
# 检查响应状态码
if response.status_code == 200:
return response.json()
else:
print("请求失败:", response.status_code)
return None
if __name__ == "__main__":
api_url = 'https://b-plugin.qixin.com/api/supplierApi/commonApi/entInfo/getEntLabel'
cookies = {
'flogger_fpid': 'd723afa6646f3f0b66bd9477f20daf9a',
'ssxmod_itna': 'YqUxBDgG5Dqx9Dl4iqYI7p0Fei=GOfQIQY042DBLfd4iNDnD8x7YDv+moO+K7KS0AWfGs0DSr3qNIjbqxpOb278XYDU4i8DCMuDQsxem=D5xGoDPxDeDADYE6DAqiOD7qDdfhTXtkDbxi3fxiaDGeDeEKODY5DhxDC0mPDwx0CfZ05QA9hO6BCTKy55FrPfxG1a40H1ASINU8LQmyhwF3GEiKDXEdDvayCS6cmDBbkMO5GZnnDTexNq7iesmRDOlq4K7Gi5chx1G05Qhx4HuDY1lcPljtDiaxqHAUDD=',
'ssxmod_itna2': 'YqUxBDgG5Dqx9Dl4iqYI7p0Fei=GOfQIQY04x8q18SqGXo=GaKSQmL7K1LKms/gSqtCaCch7Kzosjjb25=Moqidazt0BmfYMg8GNLeA2G5iLQ0=2CcCBmzuSTpqbkcHpIOkXanyvyhqxs6paZE5bKbuDspAYXZHkwgcw3fnWAxgO1cniWccGh=naqz9h0WPi3aBmSacmq47PwtA1a0EdWgOPZ=YaeQr8D2RqXicDynr8gpM=NfW8BaLQqavr91SOBxHf43W7ufo46=UbYBIPnlrYd1jyUMUbWaAf=PBXXvryQsC+fSMDKyvzHDsPmt9O35Ddm4up/05VUpxpy7jRxdnClpwWqQG0kA2eSGr4eXtAkI+liRE+5mS2mSDbR4q3TYfR9e+vSPNfAnBhvKpWjTNLY6CxNkE=E98zRR8b8bwRCAQFIlKyRlaokfqxRa1BFnf7ISM/GDxaU/iCCIZSDKu7U3FkSgXmaZzLv9T3P8HvyOzIZ/Gw/yO6PiuaxoExRa+3llb3V4wCppyjpoLbrkQaWa+2CsS0kL+t2HllaCIuqixDKwH3YFdqeduDBO4jI5ugcBY9RDxQDDLxD27GDD==',
'sid': 's%3A5Z2W1SCjv4KC14_o5Czj2DfNgcB99dbz.%2BBzQG9oEwrp%2B9R8vqznibZ7YgZE1dvhSHqIu4RqBFxI',
'aliyungf_tc': '53c02b50bd62534e99bbf7436ab0a2141ba1f02034c2a29135078e4be3eeee3f',
'acw_tc': 'ac11000117124532719681480e3ae5415231d55c62649491685d4b8b4233ae'
}
# 请求的payload数据
payload = {
'eid': 'feb3c224-9f4e-4a63-9b2b-d6caffc37d00'
}
# 发送请求并获取响应数据
result = get_company_label_with_cookies_and_payload(api_url, cookies, payload)
if result:
print(result)
之前我一直用的Selenium 我现在觉得效率太低了,还需要打开页面,等待接口加载完毕后才可以爬取,所以想改一下从接口直接cookies发送数据获取,然后cookies过期了刷新cookies再次重新获取 |