Currently, I am using mechanize to fill up a form and send a POST request, then I am doing a regex search on the response to get the data ( a floating point number).
Is there any way I can do this by just sending a POST request? I know this is possible by using a combination of any browser's Developer Tools and the requests module to send the request but I have failed to find a comprehensive tutorial. I would also like some details about the steps involved.
                        
First step: get the field name
Inspect the HTML code and find the
nameattribute of the field. For example, the comment form on this page is (in Chrome, right-click and choose "inspect element"):The field name is
comment.Step 2: assemble a dict of
name: valuefor each field (including the hidden inputs)Lets call it data:
Step 3: use the
dataargument of `requests.post'More advanced stuff
If your form has
filefields you may have to check "More complicated POST requests" in the docs. Same goes for custom authentication, cookie handling, etc.