T
T
tefoxis2020-08-12 17:20:17
Python
tefoxis, 2020-08-12 17:20:17

Python. How to log in to the site and get arguments from the url ??

Good afternoon.

There is a simple login and password form. After a successful login, info appears that the authorization is successful and the arguments user_name, user_id are added to the url.
How can I get their values?
thanks in advance

import requests

data = {"login_username":"aghgd15", "login_password":"123654"}
url = "http://localhost/login.html"
s = requests.Session()
s = requests.post(url, data=data)
print(s)

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
soremix, 2020-08-12
@SoreMix

Where is the information coming out? After redirects or what?
allow_redirects=True pass in the request

S
Sergey Karbivnichy, 2020-08-12
@hottabxp

print(s.url)

A
Alexander Sidorevich, 2020-08-14
@alexandersidorevitch

Should help :)

from urllib.parse import urlparse, parse_qs
r = urlparse(s.url)
p = parse_qs(r.query)
print(p['user_name'], p['user_id'])

V
Vadim Galtsev, 2015-03-30
@tibhar940

there is documentation for the ISP panel en.5.ispdoc.com/index.php/%D0%9A%D0%BE%D0%BD%D1%82...

M
Max, 2015-03-30
@zenwalker

Unix and Linux. System Administrator's Guide...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question