Skip to content

Instantly share code, notes, and snippets.

@azizmb azizmb/
Created Jan 2, 2013

What would you like to do?
Script to test the status for a bunch of urls, with aggregate counts in the end. Usage: python file_with_404_links.txt
import sys
from collections import defaultdict
import requests
file_name = sys.argv[1]
results = defaultdict(list)
with open(file_name) as f:
for url in f:
r = requests.get(url, allow_redirects=False)
print "%d - %s" % (r.status_code, url)
print "========================"
for status, urls in results.items():
print "%d - %d" % (status, len(urls))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.