Skip to content

Instantly share code, notes, and snippets.

@erdemarslan
Last active July 6, 2022 05:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erdemarslan/3ec02009f38f8df84c8e4807e7954af3 to your computer and use it in GitHub Desktop.
Save erdemarslan/3ec02009f38f8df84c8e4807e7954af3 to your computer and use it in GitHub Desktop.
Python check internet connection
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
@Rayan25062011
Copy link

Thanks it helped a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment