This commit is contained in:
@@ -157,10 +157,12 @@ def analyze_links(soup):
|
|||||||
if not validators.url(href):
|
if not validators.url(href):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
response = requests.head(href, timeout=5)
|
response = requests.head(href, timeout=5, allow_redirects=True)
|
||||||
if response.status_code >= 400:
|
if response.status_code >= 400:
|
||||||
broken_links.append(href)
|
broken_links.append(href)
|
||||||
except requests.RequestException:
|
except requests.RequestException as e:
|
||||||
|
# Log the exception for debugging purposes
|
||||||
|
print(f"Error checking link {href}: {e}")
|
||||||
broken_links.append(href)
|
broken_links.append(href)
|
||||||
return broken_links
|
return broken_links
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user