Search
 
SCRIPT & CODE EXAMPLE
 

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}")
Comment

PREVIOUS NEXT
Code Example
Python :: Calculate Euclidean Distance in Python 
Python :: how to make a list a string 
Python :: how to run django in jupyter 
Python :: python pipe 
Python :: python script to copy files to remote server 
Python :: python zip folder 
Python :: python extract zip file 
Python :: mkvirtualenv environment python 3 
Python :: legend font size python matplotlib 
Python :: python b before string 
Python :: backtracking python 
Python :: build a pile of cubes python 
Python :: python random randint string 
Python :: python dict setdefault 
Python :: numpy array split 
Python :: correlation with specific columns 
Python :: python pause function 
Python :: swap variables in python 
Python :: python thread function 
Python :: python print string name in pattern 
Python :: python tkinter arabic 
Python :: pyqt button clicked connect 
Python :: Game of Piles Version 2 codechef solution 
Python :: write lines python with line breaks 
Python :: seir model python 
Python :: relativefrequencies of the unique values pandas 
Python :: plt text matplotlib white background 
Python :: insert data in django models 
Python :: how to get the type of numpy array 
Python :: how to put legend outside pie plot in python 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =