I am trying to check if a URL is valid URL by doing this:
def check_urlstatus(url):
h = httplib2.Http()
try:
resp = h.request("http://" + url, 'HEAD')
if int(resp[0]['status']) < 400:
return 'ok'
else:
return 'bad'
except (httplib2.ServerNotFoundError, UnicodeError, httplib2.RelativeURIError):
return 'bad'
But some URLs dont seem to pass even if they are valid. e.g. this one: www.healthpolicyjrnl.com
I am getting the error:
Redirected more times than rediection_limit allows.
how can I catch this error? i would return bad
for this.
second question is:
am I missing any other potential Error which I should catch in except
?