Python Code to Check Website is Live Or Down

By using this python code we can check any website is accessible or not. (Python Code to Check is Website Live Or Down)


import requests

def check_website_response(url):
        response = requests.get(url)
        # Check the response status code
        if response.status_code == 200:
            print("Website is accessible!")
            print(f"Website returned a non-200 status code: {response.status_code}")
    except requests.exceptions.RequestException as e:
        print("Error occurred while connecting to the website:", e)

# Example usage
url = input("Enter the website URL: ")


Enter the website URL:
Website is accessible!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top