diff --git a/scripts/test_urls.py b/scripts/test_urls.py index 483a98a588b56c27ed3442b04d9857dd369683fd..d7ce8fa077fb72aa81d606446cd248fd8b2ba608 100755 --- a/scripts/test_urls.py +++ b/scripts/test_urls.py @@ -82,6 +82,11 @@ headers={ "User-Agent" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36", } +session = requests.Session() +adapter = requests.adapters.HTTPAdapter(max_retries=3) +session.mount('http://', adapter) +session.mount('https://', adapter) + broken = [] for url in urls: print("%s : " %(url), end='') @@ -90,7 +95,7 @@ for url in urls: status = None resp = None try: - resp = requests.head(url, headers=headers, allow_redirects=True, timeout=60, verify=False) + resp = session.head(url, headers=headers, allow_redirects=True, timeout=60, verify=False) status = resp.ok resp.close() except Exception as e: @@ -102,7 +107,7 @@ for url in urls: # that's not got a 200 status code with GET as well. if not status: resp = None - resp = requests.get(url, headers=headers, allow_redirects=True, timeout=60, verify=False) + resp = session.get(url, headers=headers, allow_redirects=True, timeout=60, verify=False) status = resp.ok resp.close() except Exception as e: