File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ #This code is made by MRayan Asim
2+ #Packages needed:
3+ #pip install requests
4+ import requests
5+ import time
6+
7+ def check_website_connectivity (url ):
8+ try :
9+ start_time = time .time ()
10+ response = requests .get (url )
11+ end_time = time .time ()
12+
13+ if response .status_code == 200 :
14+ speed = end_time - start_time
15+ print (f"The website { url } is reachable." )
16+ print (f"Response time: { speed :.2f} seconds" )
17+ else :
18+ print (f"Error: The website { url } returned a status code { response .status_code } ." )
19+ except requests .RequestException as e :
20+ print (f"Error: Unable to connect to the website { url } ." )
21+ print (f"Exception: { e } " )
22+
23+ if __name__ == "__main__" :
24+ user_url = input ("Enter the website URL: " )
25+ check_website_connectivity (user_url )
You can’t perform that action at this time.
0 commit comments