Created
January 2, 2013 13:45
-
-
Save azizmb/4434680 to your computer and use it in GitHub Desktop.
Script to test the status for a bunch of urls, with aggregate counts in the end. Usage: python test_urls.py file_with_404_links.txt
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 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) | |
results[r.status_code].append(url) | |
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