python传递json参数
一般requests用
url = "http://.................."
data = {
"page": "1",
}
response = requests.post(url=url, json=data).text
在scrapy里需注意:
def start_requests(self):
start_url = "http://...................."
for page_num in range(1, 2):
data = {
"page": str(page_num),
}
yield scrapy.Request(url=start_url, method="POST", body=json.dumps(data), headers={
"Content-Type": "application/json"
}, callback=self.list_parse)