Answers for "python check if website is reachable"

0

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}")
Posted by: Guest on August-08-2021

Code answers related to "python check if website is reachable"

Python Answers by Framework

Browse Popular Code Answers by Language