R
R
richkule2017-09-22 12:42:50
Python
richkule, 2017-09-22 12:42:50

POST request in request python module?

Programmatically send a POST request

import requests
url = "https://login.1c.ru/login?service=https%3A%2F%2Freleases.1c.ru%2Fpublic%2Fsecurity_check"
data = {'username':'Test','password':'Test2'}
print(requests.post(url, data = data).text)

But for some reason, in the response, username does not take any value, and 2 values ​​​​appear in password and one of them is equal to test2
input id="password" name="password" class="required span12 form-control" tabindex="2" value="Test2" type="password" value=""

input id="username" name="username" class="required span12 form-control" tabindex="1" spellcheck="false" type="text" value="

Moreover, when I specify in the request, the values ​​\u200b\u200bare allowed for "execution" (The site itself fills in these values), then in the response I receive information that an error has occurred on their server. In other words, my POST requests affect the values ​​of other variables, but not the username and password, what's the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
x67, 2017-09-22
@richkule

Go to the site in a browser, open the request manager (network tab for ff),
enter your username and password, click the button. Now you need to find the request that went to the server. Watch and analyze all its headers, parameters. You need to programmatically make exactly the same request. Moreover, if some data is not static, but is generated during / before the request is executed, you need to do the same. For example, in a request, in addition to the login / password, there may be a current time. And in order for the script to work, you must also send this time to the server.
What you are sending now will not be sent in this form by any browser.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question