Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python check if internet is available

import urllib.request

def internet_on():
    try:
        urllib.request.urlopen('http://216.58.192.142', timeout=2)
        return True
    except:
        return False
Comment

python check if there is internet

try:
    import httplib  # python < 3.0
except:
    import http.client as httplib


def have_internet():
    conn = httplib.HTTPSConnection("8.8.8.8", timeout=5)
    try:
        conn.request("HEAD", "/")
        return True
    except Exception:
        return False
    finally:
        conn.close()
Comment

python check if there is internet connection

# pip install pythonping
from pythonping import ping
def internet_connected(test_ip_address="8.8.8.8"):
    return ping(test_ip_address).success()
Comment

PREVIOUS NEXT
Code Example
Python :: python join array of ints 
Python :: install mamba conda 
Python :: tkinter bind to window close 
Python :: stopwatch in python 
Python :: how to download file from python 
Python :: numpy mean 2 arrays 
Python :: python pyodbc install 
Python :: python cv2 screen capture 
Python :: opencv draw two images side by side 
Python :: model load pytorch 
Python :: check if image is empty opencv python 
Python :: python pil image flip 
Python :: discord py on ready 
Python :: STandardScaler use example 
Python :: python find all pairs in list 
Python :: python alphabet 
Python :: delete element of a list from another list python 
Python :: ggplot2 histogram 
Python :: tensot to numpy pytorch 
Python :: flask if statement 
Python :: timedelta year python 
Python :: how to add static files in django 
Python :: fill missing values in column pandas with mean 
Python :: python jwt parse 
Python :: dictionary sort python 
Python :: dollar 
Python :: Pytube mp3 
Python :: pandas has no attribute scatter_matrix 
Python :: numpy remove rows containing nan 
Python :: python random string 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =