Created
September 3, 2014 18:06
-
-
Save pronto/01ad52032ebd8ad20488 to your computer and use it in GitHub Desktop.
http server head location follow
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
it follows the header location FOR EVER | |
% ./head.py http://t.co/xoE6KECoaL | |
http://ift.tt/Wcf2oC | |
https://plus.google.com/109306878344142850405/posts/a9MCxCwvN4x | |
https://plus.google.com/+FredRichards/posts/a9MCxCwvN4x |
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
#!/usr/bin/env python2.7 | |
import requests | |
import sys | |
def get_loc(url): | |
try: | |
h=requests.head(url).headers['location'] | |
return h | |
except KeyError: | |
return 'END' | |
urlcnt=len(sys.argv)-1 | |
if urlcnt == 0: | |
print 'please enter in a url' | |
sys.exit(1) | |
headloop = get_loc(sys.argv[1]) | |
while headloop != 'END': | |
print headloop | |
headloop = get_loc(headloop) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment