Skip to content

Instantly share code, notes, and snippets.

@keybits
Created March 20, 2014 11:26
Show Gist options
  • Save keybits/9661776 to your computer and use it in GitHub Desktop.
Save keybits/9661776 to your computer and use it in GitHub Desktop.
Testing redirects with Python 3 and requests
import requests
redirects = {
"http://github.com/": "https://github.com/",
"http://www.minktoast.net/": "http://minktoast.net/",
}
for key, value in redirects.items():
r = requests.get(key)
if r.url == value:
print("Redirect OK for %s" % (value))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment