Search code examples
pythonrequestpython-requestsform-data

How to construct this form data to make a post request using python


I am trying to write a post request using python's request library. I am trying to fetch details of some startups from angel.co website.

When I am inspecting the request using firefox's developer tools, the post request contains the form data like this - filter_data[locations][]=1647-India.

I want to know how can I construct this exact form data in python so that I can make the request and get the same result, as I am getting in my browser.


Solution

  • The data filter_data[locations][]=1647-India is like any other data you post. You can feed them to requests.post() like this:

    requests.post(url, data={'filter_data[locations][]' : '1647-India'}) 
    

    As in comments, there is QuickStart User Guide how to make complex requests.