M
M
MARMELAD032015-10-13 18:21:20
Python
MARMELAD03, 2015-10-13 18:21:20

How to make a post request in python?

I need to click on a button on a website How can I click on a button on a website using python? I dealt with it and realized that this method does not suit me (it is too slow). Decided to choose another. It is necessary to ring with the help of the post request "click on the button". As I understand it, you need to specify cookies in this post request. I found a library for working with http "request", but there is no Russian documentation for it. Help me to understand.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valery Ryaboshapko, 2015-10-13
@valerium

To make a POST request, use the requests.post() function.
Through the data argument, pass a dictionary with variables, if they are needed. The response variable contains the response object, which has the cookies attribute, which contains a dictionary with cookies. You can pass these cookies in the next request using the (what a surprise!) cookies parameter.
In general, the request module is incredibly good, I have never seen such an intuitive and convenient way to work with HTTP. What a single .json() method is worth!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question