Last active
July 6, 2022 05:29
-
-
Save erdemarslan/3ec02009f38f8df84c8e4807e7954af3 to your computer and use it in GitHub Desktop.
Python check internet connection
This file contains hidden or 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 urllib3 | |
def check_internet_conn(): | |
http = urllib3.PoolManager(timeout=3.0) | |
r = http.request('GET', 'google.com', preload_content=False) | |
code = r.status | |
r.release_conn() | |
if code == 200: | |
return True | |
else: | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks it helped a lot!