import urllib.request, urllib.error def getStatus(url): try: return urllib.request.urlopen(url).getcode() except urllib.error.HTTPError as e: return e.code except urllib.error.URLError: return False