How to get website status code with python
This tutorials is How to get website status code with python urllib
. and HTTP status code is a server response to a request representing website status. HTTP status code response of 200 represents the request was successful.
urllib.request.urlopen(url):
The URL of the website to retrieve a response.client.HTTPResponse.getcode():
This response to get the HTTP status code.
Example
import requests import urllib response = urllib.request.urlopen("https://devnote.in") status_code = response.getcode() print(status_code) OUTPUT: 200
=== OR ===
import requests response = requests.get("https://google.com") if(response.status_code == 200): print ("Success") else: print ("Fail") OUTPUT: Success