I am trying to use the Python’s requests library to insert my credentials in a website. However i don’t know how to verify if the login is successful. The page that i am trying to insert my credentials is this. As i can see, the name of the username entry is username
and the name of the password entry is passname
from the HTML code (the form element). Here is the code that i use:
payload = {'username': 'my_username', 'passname': 'my_password'}
url = 'https://www.e-shop.gr/usr_login.phtml'
res = requests.post(url, data=payload, verify=False)
print(res.status_code)
print(res.history)
The status code of the response is 200
and the history is a list with a 302
response (redirection).
2
Answers
You can check based on the
status_code
, if the status code is 200 then the login was successful. And also you can mixed it up based on the history redirection and validate either thetoken
was in the response headers or body