Jun-14-2017, 12:44 PM
Hi, i made a program that reads a URL from textfile and checks if that websites status is <=400, if it is, it will return "website is running" and saves that to a list and checks the next address in the textfile. This works as long as the website is reachable and returns status <= 400.
But when i add a random address www.asdasdasda123sd.com, which doesnt exist the program stops running completely. Need help solving this, code below and error also, thank you.
never mind, im stupid. found my mistake as soon as i posted problem, can delete this :D
But when i add a random address www.asdasdasda123sd.com, which doesnt exist the program stops running completely. Need help solving this, code below and error also, thank you.
def getApacheStatus(urlStatus): r = requests.head(urlStatus['url']) try: if r.status_code <= 400: return 'connected' else: return 'website down' except: pass
Error:requests.exceptions.ConnectionError: HTTPConnectionPool(host='www.asdasdasda123sd.com', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f8424b7de10>: Failed to establish a new connection: [Errno -2] Name or service not known',))
EDIT by user:never mind, im stupid. found my mistake as soon as i posted problem, can delete this :D