B
B
beaver_872020-04-15 15:22:45
Python
beaver_87, 2020-04-15 15:22:45

Authorization requests post python, getting empty data?

I'm trying to authorize via requests.post, but authorization fails and I get empty data

import requests
headers = {
    "User-Agent":
        "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36",
    'Content-Type': 'text/html; charset=UTF-8'}
s = requests.Session()
s.headers.update(headers)
s.get('https://edu.tatar.ru')
s = s.post('https://edu.tatar.ru/logon', data={'main_login': 'login', 'main_password':'pass'})
print(s.text)

s.text contains nothing

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Karbivnichy, 2020-04-15
@beaver_87

Try like this:

s = requests.Session()
s.headers.update(headers)
s.post('https://edu.tatar.ru/logon', data={'main_login': 'login', 'main_password':'pass'})
response = s.get('https://edu.tatar.ru')
print(response.text)

Perhaps post does not return anything, but only receives cookies.
I do not have a login to this site, so I used a random login and password. In response, I received only 'Response [200]' (which is a bit strange), and also an empty response.

D
Dimonchik, 2020-04-15
@dimonchik2013

mean, here listen to
the first action for any site you teach, right? you read the article, you do according to the article, right
?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question