构造data时双引号导致403错误

xiaoxiao2025-05-17  37

for j in column: print(j) for i in range(1, 4): data = {"keyword": "%s" % j, "filter": "{\"location\":[],\"industryshort\":[],\"registercapital\":\"0\",\"establishment\":\"0\",\"entstatus\":\"0\",\"enttype\":\"0\"}", "scope": "", "pagesize": 10, "page": i} print(data) t = requests.post(url=url, verify=False, headers=headers, data=json.dumps(data)) a = t.text print(json.loads(a))

近期在爬取某些网站时,data中有两个数据需要参数化,但是自己的代码一直报403错误,最后发现是构造data时双引号的识别问题,我一直写的"keyword":j,最后发现,改成: “keyword”: “%s” % j,代码就不会再报403错误。

转载请注明原文地址: https://www.6miu.com/read-5030251.html

最新回复(0)