Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python detect internet connection

try:
    import httplib
except:
    import http.client as httplib

def have_internet():
    conn = httplib.HTTPConnection("www.google.com", timeout=5)
    try:
        conn.request("HEAD", "/")
        conn.close()
        return True
    except:
        conn.close()
        return False
# Code by Ivelin on Stack overflow
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 :: first 2 terms 
Python :: install python decouple 
Python :: get current working directory python 
Python :: get request python 
Python :: how to raise a error in python 
Python :: jupyter notebook how to set max display row columns matrix numpy 
Python :: python roll a die 
Python :: how to play a mp3 file in python 
Python :: remove minimize and maximize and cancle button python pyqt5 
Python :: plt.xlabel not working 
Python :: python add current directory to import path 
Python :: python use .env 
Python :: python detect tty 
Python :: seaborn styles 
Python :: age calculator in python 
Python :: import models 
Python :: from csv to pandas dataframe 
Python :: python implode list 
Python :: python save string to text 
Python :: seaborn plot dpi 
Python :: pandas read csv without index 
Python :: log transform pandas dataframe 
Python :: what is nea in python 
Python :: how to run pytest and enter console on failure 
Python :: pip install Parser 
Python :: pandas get numeric columns 
Python :: converting a string to a dictionary in python 
Python :: override the text in buttons django admin 
Python :: how do i change the hue color in seaborn 
Python :: pyplot legend outside figure 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =