The formdata parameter of scrapy.FormRequest. If you want to pass in a dictionary with value as the list, what do you do?

construct a POST request using the FormRequest object of scrapy , where the formdata parameter is a dictionary, the dictionary has only one kv, and v is a list, how to send it as post content? Several methods have been tried, all of which fall short of the expected response:

.
{"user_list":[{"user_id":"A31FA9502C95CC071C6098B49F62B4657A82F2BFCF5D59163A1B9F73D4239CBD","lang":"zh_CN"}]}

if you use the requests library, you can get the correct response by writing it this way:

user_id = "A31FA9502C95CC071C6098B49F62B4657A82F2BFCF5D59163A1B9F73D4239CBD"

url = "http://ssl.gongyi.qq.com/cgi-bin/gy_user_extra_display.fcgi"
payload = "{\"user_list\":[{\"user_id\":\"%s\",\"lang\":\"zh_CN\"}]}" % user_id
headers = {
    "User-Agent": "EnterpriseInquiry/2.1.4 (iPhone; iOS 11.2.2; Scale/2.00)",
    "Content-Type": "application/json",
}
r = requests.post(url, data=payload, headers=headers)
Mar.01,2021

is there a solution to this problem? I have encountered the same problem recently


I have encountered the same problem. Has anyone solved it?

Menu