I used requests to login to a website using the correct credentials initially. Then I tried the same with some invalid username and password. I was still getting response status of 200. I then understood that the response status tells if the corresponding webpage has been hit or not. So now my doubt is how to verify if I have really logged in to the website using correct credentials
HTTP status codes are usually meant for the browsers, or in case of APIs for the client talking to the server. For normal web sites, using status codes for semantical error information is not really useful. Overusing the status codes there could even cause the browser to not render responses correctly.
So for normal HTML responses, you would usually expect a code 200 for almost everything.
In order to check for errors, you will then have to check the—application specific—error output from the HTML response. A good way to find out about these signs is to just try logging in from the browser with invalid credentials and then check what output is rendered. Or as many sites also show some kind of user menu once you’re logged in, check for its existence to figure out if you’re logged in. And when it’s not there, the login probably failed.
How to verify that we have logged in correctly to a website using requests in python?