scrapy post请求 multipart/form-data

 

https://stackoverflow.com/questions/48343098/how-to-use-scrapy-post-the-multipart-form-data-to-the-api

 

https://stackoverflow.com/questions/12385179/how-to-send-a-multipart-form-data-with-requests-in-python

 

https://blog.csdn.net/summerpowerz/article/details/80293235

"Content-Type": "multipart/form-data; boundary=----WebKitFormBoundaryp20mobDusfUBBpya",
''''
安装依赖包
pip install requests_toolbelt
''''

from requests_toolbelt import MultipartEncoder

headers = {
"Content-Type": "multipart/form-data; boundary=----WebKitFormBoundaryp20mobDusfUBBpya"
}
data = {
"ANONYMOUS_TOKEN": ANONYMOUS_TOKEN,
"ENTRY": ENTRY,
"ENTRY_TYPE": ENTRY_TYPE
}

encoder = MultipartEncoder(data, boundary='----WebKitFormBoundaryp20mobDusfUBBpya')
me_body = encoder.to_string()

yield Request(url,
method='POST',
callback=self.parse_details,
meta={'handle_httpstatus_list': [301, 302]},
body=me_body,
headers=headers,
dont_filter=True
)

 

 

 


 

posted @ 2020-07-10 15:31  AngDH  阅读(595)  评论(0编辑  收藏  举报