Created
May 20, 2020 05:09
-
-
Save Allwin12/7948a8dc80f16edda5bdc76b4a0c4ad6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def checkInternetRequests(url='http://www.google.com/', timeout=3): | |
try: | |
# r = requests.get(url, timeout=timeout) | |
r = requests.head(url, timeout=timeout) | |
return True | |
except requests.ConnectionError as ex: | |
print(ex) | |
return False | |
connectivity = checkInternetRequests() | |
if connectivity is True: | |
print("Connection can be established!") | |
else: | |
print("Not connected to the internet!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment