今天一个朋友遇到了下面这种请求,向我询问,我也是第一次见到,于是Google了一下。把解决方法记下来备忘。
from urllib3 import encode_multipart_formdata
import requests
data = {"districtId":"1","page":1,"pageSize":"10"}
headers = {
"Content-Type": "multipart/form-data; boundary=eaaee54a-3b9a-4b60-9d98-0b5f27d9c4ef",
"User-Agent": "okhttp/3.10.0"
}
d = encode_multipart_formdata(data, boundary='eaaee54a-3b9a-4b60-9d98-0b5f27d9c4ef')
r = requests.request('POST', url, data='\r\n'.join(d), headers=headers, verify=False)