M
M
Maxim Solovyov2020-03-22 00:36:13
Python
Maxim Solovyov, 2020-03-22 00:36:13

Who can help with the problem of authorization through python?

Good afternoon, help please. I need to parse site elements that appear after authorization.
After running the code, it displays ReturnUrl

import urllib.request
import bs4
from bs4 import BeautifulSoup
import requests
import json


def main():
    data = {
        "login": "maks********20",
        "password": "V******35"
    }
    r = requests.post('https://login.school.mosreg.ru/user/login', data=data)
    print(r.status_code)
    print(r.text)


if __name__ == '__main__':
    main()


Console output:
200
{"returnUrl":"https://school.mosreg.ru:443/?utm_source=school.mosreg&utm_medium=uslugi&utm_campaign=login","forceRedirect":false}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2020-03-22
@BeryWolf

Either use requests.session() or manually receive cookies after authorization and pass them when requesting pages with the necessary data at the necessary urls.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question