How to get an HTTP status code in Python

Getting an HTTP status code returns a status code representing the state of a website. For example, an HTTP status code response of 200 represents the request was successful.

Solution for How to get an HTTP status code in Python : You can use requests.head() and requests.Response.status_code to get an HTTP status code Call requests.head(url) with url as the URL of the website to retrieve a status code. Use requests.Response.status_code with the result of the previous step as requests.Response to get the HTTP status code.


how-to-get-an-http-status-code-in-python