Python script to check HTTP status and redirect chains

Here’s a quick and dirty Python script that goes through a list of URLs, and for each URL checks HTTP status codes (200, 301, 404, etc.), along with number of redirects and redirect chains (each redirect destination).  Saves output into a text file (you can modify to save to CSV, but I used text import feature in Excel to import tab-delimited data).

Well, damn hosted WordPress doesn’t let me paste code correctly, so here’s the link to Gist.

Update: and here’s how to post Gist properly:

Screen Shot 2015-10-01 at 10.59.23 AM

2 thoughts on “Python script to check HTTP status and redirect chains

  1. Hey Tanya, awesome script…this still worked for me 5 years on! The only thing I had to change was adding brackets to the print function on line 6. Not sure if that’s a Python2 to Python3 thing as I’m still fairly new to this language, but either way it worked great in the end.

    Thanks for sharing this, it’s really helpful to see and run other people’s code examples :-)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s