From be3fde9a6e64d62f93d0c725de2c377134fbfdda Mon Sep 17 00:00:00 2001 From: eric Date: Thu, 4 May 2023 12:04:31 -0400 Subject: [PATCH] add handling for bad redirects --- doab_check/check.py | 11 ++++++++++- doab_check/templates/index.html | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doab_check/check.py b/doab_check/check.py index bc0e35c..68440d2 100755 --- a/doab_check/check.py +++ b/doab_check/check.py @@ -36,8 +36,17 @@ class ContentTyper(object): r = requests.get(url, verify=False) r.status_code = 511 return r - except: + except requests.exceptions.ConnectionError: + try: + r = requests.get(url, allow_redirects=False, headers=HEADERS) + return r + except Exception as e: + # unexplained error + logger.exception(e) + return None + except Exception as e: # unexplained error + logger.exception(e) return None def calc_type(self, url): diff --git a/doab_check/templates/index.html b/doab_check/templates/index.html index bb8b425..48f5a9e 100644 --- a/doab_check/templates/index.html +++ b/doab_check/templates/index.html @@ -36,9 +36,11 @@ View the list of publishers whose links we've c When a link is checked we record the status code and content type returned by the web server.