Why not change the condition of the site when I send an http request?

Can not realize the push of a button on the website with an http request?
One of the sites there is a button that you can click and change the state of the button. The transition to a new page occurs.
If you look through the developer console, clicking on the button occurs the following HTTP request:

Request URL: https://example.ru/dk?cmd=FriendshipRequests
Request Method: POST
Status Code: 200
Referrer Policy: origin


target: 412345678922
st.modes: wideportlet
list:
disableShortcut: false
largeCard: false
st.sizes:
action: decline
st._aid: MyFriends_DeclineFriend
gwt.requested: 5bf8572fT1571234567832


Based on these data, form the following code:
data = { 'target': 412345678922,
 'st.modes': 'wideportlet',
 'list': ",
 'disableShortcut': 'false',
 'largeCard': 'false',
 'st.sizes': ",
 'action': 'decline',
 'st._aid': 'MyFriends_DeclineFriend',
 'gwt.requested': '5bf8572fT1571234567832'
}
 response = requests.post('https://example.ru/dk?cmd=FriendshipRequests', data=data)

In response to receiving status_code of 200, but after checking I see that the emulation of key press did not happen. On the website there are no changes.

What is my mistake?How to form a query?
Why not change the condition of the site when I send an http request?
April 4th 20 at 00:49
1 answer
April 4th 20 at 00:51
How to check?
A rough plan like this
1. to start the session, make a request to get session data
2. if you want to log, then do this query (often, but not always, can be combined with 1)
3. parse the html to get the data for your request, make a request

Besides all this on the website may be protected by bots, then you need to pretend to be a normal browser, at least add the user agent, max go to the selenium and not the fact that it will help.
Plan the following:
1. Autorizovany on the website, with saved cookies (via the session).
2. Turn to the desired page. Party. Pull the desired data for the query.
3. Form a request and send it.

On the selenium this algorithm works. But I want to leave him. - alyson.Cruickshank60 commented on April 4th 20 at 00:54
@alyson.Cruickshank60, protection from bots, perhaps part of the data happens via js, to fulfill requests that can not (and what you took from the console, rather irrelevant for the other session). Well, the setup user agent, can ride. - Kevin.Moo commented on April 4th 20 at 00:57
@Kevin.Moo, in management, as there is Requests Headers - these option also need to pass in the request?) And then I transmit only Data) - alyson.Cruickshank60 commented on April 4th 20 at 01:00

Find more questions by tags Python