Python Forum
Check network WITHOUT use internet - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Networking (https://python-forum.io/forum-12.html)
+--- Thread: Check network WITHOUT use internet (/thread-30617.html)



Check network WITHOUT use internet - ATARI_LIVE - Oct-28-2020

I know one of code is works great as:
try:
    import httplib
except:
    import http.client as httplib

def checkInternetHttplib(url="www.google.com", timeout=3):
    conn = httplib.HTTPConnection(url, timeout=timeout)
    try:
        conn.request("HEAD", "/")
        conn.close()
        return True
    except Exception as e:
        print(e)
        return False
That is use the internet...
But I would like to use local like 192.168.1.1 WITHOUT the internet, how can I code this? url="192.168.1.1" ?


RE: Check network WITHOUT use internet - Larz60+ - Oct-28-2020

try replacing "www.google.com" with local ip address