I am trying to scrape a website where I can find the url has a post request with payload parameters as below. I am not sure how to make it to a dictionary in payload and send it in formdata. All the below code comes under Request with payload how do I send this in formdata??
------WebKitFormBoundaryj9yKl83Zu7ki71zE
Content-Disposition: form-data; name="textquery"
852432-B21
------WebKitFormBoundaryj9yKl83Zu7ki71zE--
How to format this and do I send this using python-scrapy?
You should send it as raw request body with appropriate header:
body = '''--WebKitFormBoundaryj9yKl83Zu7ki71zE
Content-Disposition: form-data; name="textquery"
852432-B21
--WebKitFormBoundaryj9yKl83Zu7ki71zE--
'''
yield Request(url, method='POST', body=body,
headers={'Content-Type': 'multipart/form-data; boundary=WebKitFormBoundaryj9yKl83Zu7ki71zE'})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.