Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Check if the url is reachable or not in Python

import requests

def url_checker(url):
	try:
		#Get Url
		get = requests.get(url)
		# if the request succeeds 
		if get.status_code == 200:
			return(f"{url}: is reachable")
		else:
			return(f"{url}: is Not reachable, status_code: {get.status_code}")

	#Exception
	except requests.exceptions.RequestException as e:
        # print URL with Errs
		raise SystemExit(f"{url}: is Not reachable 
Err: {e}")
        
# @Zenonymous
Comment

PREVIOUS NEXT
Code Example
Python :: filter a pandas dataframe by length of list in a column 
Python :: legend text color matplotlib 
Python :: area of trapezium 
Python :: load pt file 
Python :: python custom exception 
Python :: Groups the DataFrame using the specified columns 
Python :: read multiple images cv2 
Python :: python delete from dictionary 
Python :: python dictionary get keys and values 
Python :: turtle keep window open 
Python :: python minigame 
Python :: create custom exception python 
Python :: how to run shell command in python 
Python :: python logging basicConfig+time 
Python :: csr_matric scipy lib 
Python :: extract text from pdf python 
Python :: end in print python 
Python :: python logging to syslog linux 
Python :: how to get value from set in python 
Python :: python create dictionary from csv 
Python :: - inf in python 
Python :: df astype 
Python :: how to shuffle array in python 
Python :: ModuleNotFoundError: No module named 
Python :: python glfw 
Python :: python timeout exception 
Python :: astype python 
Python :: how to make a leaderboard in python 
Python :: seaborn.distplot() 
Python :: python delete all occurrences from list 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =