Skip to content

Commit

Permalink
Simplify link checker
Browse files Browse the repository at this point in the history
... and debug a bit.
  • Loading branch information
QuLogic committed Feb 15, 2024
1 parent 61c26ab commit 6d23ed6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions check-links.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

refs = [ref for ref in pdf.get_references() if ref.reftype == 'url']

status_codes = list(map(lambda ref: pdfx.downloader.get_status_code(ref.ref), refs))
status_codes = [pdfx.downloader.get_status_code(ref.ref) for ref in refs]

broken_links = [refs[idx].ref for idx in range(len(refs)) if status_codes[idx] != 200]
broken_links = [(ref.ref, code) for ref, code in zip(refs, status_codes) if code != 200]

# it seems that Twitter does not respond well to the link checker and throws a 400
if all(['twitter.com' in url for url in broken_links]):
if all(['twitter.com' in url for url, _ in broken_links]):
sys.exit(0)
else:
print('Broken links:', broken_links)
Expand Down

0 comments on commit 6d23ed6

Please sign in to comment.