[SOLUCIONADO] Cómo visitar pagina -website con python?

Iniciado por n00bcoder, Enero 12, 2016, 11:24:05 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Enero 12, 2016, 11:24:05 PM Ultima modificación: Enero 13, 2016, 03:23:24 PM por Gabriela
Hola quisiera saber como seria posible visitar alguna pagina con python y saber si esta online o no ? de antemano gracias.   :P

Enero 13, 2016, 12:32:34 PM #1 Ultima modificación: Enero 13, 2016, 12:35:47 PM por Barlan
Puedes programar un script usando la librería You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login, y después usar la función getcode(), que te devolverá el código de estado de la petición HTTP (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login). Si el número es un 200, es porque la página está online, si no, es porque no lo está.

Ejemplo:
Código: python

import urllib.request

status = urllib.request.urlopen("http://underc0de.org").getcode()
print(status)




Gracias  @You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login  ;D  ;D