Last active
February 14, 2016 23:47
-
-
Save syxolk/540e329f287624c9ddaf to your computer and use it in GitHub Desktop.
Revert the process of url shortening: Traverse and show redirects of a URL.
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 python3 | |
import sys, requests | |
USER_AGENT = 'Mozilla/5.0 (Windows NT 6.3; rv:44.0) Gecko/20100101 Firefox/44.0' | |
if __name__ == '__main__': | |
if len(sys.argv) != 2: | |
print('Usage: urlextender.py <url>') | |
sys.exit(1) | |
r = requests.get(sys.argv[1], headers={'User-Agent': USER_AGENT}) | |
for h in r.history: | |
print(h.url) | |
print(r.url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment