Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib2
- import socket
- import logging
- def check_url( url, timeout=5 ):
- try:
- return urllib2.urlopen(url,timeout=timeout).getcode() == 200
- except urllib2.URLError as e:
- return False
- except socket.timeout as e:
- print False
- ############## Estas dos lineas no las uses
- print check_url("http://www.google.com") # Envia True por que existe
- print check_url("http://xasx.cl") #Envia False por que no esta DIsponible
- ########################En Desarrolloso-->>> first TEST
- #def check_url( url, timeout=5 ):
- # try:
- # return urllib2.urlopen(url,timeout=timeout).getcode() == 200
- # except urllib2.URLError as e:
- # return False
- # except socket.timeout as e:
- # print False # ACTIVA ESTAS LINEAS DE AQUI PAR ABAJO ####
- # checker = check_url("http://" + args.host)
- # if(checker == True):
- # logging.info("El Servidor esta: ONLINE")
- # if not(checker == True):
- # logging.info("El Servidor esta: OFFLINE")
- ###################################
Advertisement
Add Comment
Please, Sign In to add comment