Reputation: 485
I want to check whether I am successfully login by getting the status code. So, when I input the wrong account info and post the request, the status code of "Verifylogin.jsp" will return a error 302 (check by F12). What can I do with the response
to achieve that? My code work for login the website, but I just dont know how to get the response header. Thank you so much for your reply.
def check_login(username, password):
url = 'http://example.com/login/VerifyLogin.jsp'
payload = {'loginid': username,
'userpassword': password,}
r = requests.Session()
response = r.post(url, data= payload)
Upvotes: 1
Views: 473
Reputation: 66
response.status_code
is what you need.
Here is the manual:
http://docs.python-requests.org/en/master/user/quickstart/#response-status-codes
Upvotes: 2