“Python Compruebe si hay internet” Código de respuesta

Python Check si Internet está disponible

import urllib.request

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

Python Compruebe si hay 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()
cabiste

Respuestas similares a “Python Compruebe si hay internet”

Preguntas similares a “Python Compruebe si hay internet”

Más respuestas relacionadas con “Python Compruebe si hay internet” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código