Skip to content

Instantly share code, notes, and snippets.

@jhorneman
Created August 2, 2014 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhorneman/a14e49c3a9fc8a31a257 to your computer and use it in GitHub Desktop.
Save jhorneman/a14e49c3a9fc8a31a257 to your computer and use it in GitHub Desktop.
Small script to check for dead links
import requests
def check_link(_url):
_url = _url.strip()
if not _url:
return
if not _url.startswith('http://'):
_url = 'http://' + _url
try:
r = requests.get(_url)
except requests.ConnectionError:
print "Connection Error", _url
else:
if r.status_code != 200:
print r.status_code, _url
if __name__ == "__main__":
for line in open("links.txt"):
check_link(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment