Created
July 22, 2022 22:37
-
-
Save sellisd/9654faf1f2617f8e634ab149c885a119 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
def is_broken(link) -> bool: | |
response = requests.get(link) | |
print(response.status_code) | |
if response: | |
return True | |
else: | |
return False | |
def page_not_outdated(html_file)->bool: | |
errors = False | |
with open(html_file, 'r') as f: | |
contents = f.read() | |
soup = BeautifulSoup(contents, 'html.parser') | |
for link in soup.find_all('a'): | |
if is_broken(link): | |
errors = True | |
print(f"broken link in {html_file} {link}") | |
if errors: | |
return False | |
else: | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment