Skip to content
Advertisement

Recreate POST request with WebKitFormBoundary using Python’s requests

I am attempting to scrape some data from a website using a POST request with the Python requests library. Unfortunately I am unable to post a link to the page as you must be signed in to the website to site to use it.

The request I am trying to replicate has the file extension .ehtml and this is part of the Request payload I am looking to recreate:

JavaScript

Using some help from some of the questions on stackoverflow, I have managed to recreate it this far:

JavaScript

That was done using this code:

JavaScript

I believe the last thing I am missing is the WebKitFormBoundary part, I am unable to find anywhere how to insert that part. This is my first time scraping using an .ehtml file, so if I have missed anything else obvious, all help is much appreciated.

Advertisement

Answer

The exact name of the boundary does not matter as long as it is declared in the header:

JavaScript

With this header the boundaries would be

JavaScript

There server will take a look at the Content-Type header and figure out the body parts.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement