Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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
Source by pytutorial.com #
 
PREVIOUS NEXT
Tagged: #Check #url #reachable #Python
ADD COMMENT
Topic
Name
1+1 =