- webpage = urllib.request.urlopen(request, timeout=15)
- except (urllib.error.HTTPError, urllib.error.URLError,
- UnicodeError, http.client.BadStatusLine,
- UnicodeDecodeError) as error:
- print("TROUBLE FOLLOWING URL: " + str(error))
- continue
- charset = webpage.info().get_content_charset()
- if not charset:
- charset = "utf-8"
- content_type = webpage.info().get_content_type()
- if content_type not in ('text/html', 'text/xml',
- 'application/xhtml+xml'):
- print("TROUBLE INTERPRETING URL: bad content type "
- + content_type)
+ r = requests.get(url, timeout=15)
+ except (requests.exceptions.TooManyRedirects,
+ requests.exceptions.ConnectionError,
+ requests.exceptions.InvalidURL,
+ requests.exceptions.InvalidSchema) as error:
+ notice("TROUBLE FOLLOWING URL: " + str(error))