Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python check if website is reachable

import requests

URL = "https://api.github.com"

try:
    response = requests.head(URL)
except Exception as e:
    print(f"NOT OK: {str(e)}")
else:
    if response.status_code == 200:
        print("OK")
    else:
        print(f"NOT OK: HTTP response code {response.status_code}")
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #check #website #reachable
ADD COMMENT
Topic
Name
4+9 =