Instantly share code, notes, and snippets.

Embed
What would you like to do?
Revert the process of url shortening: Traverse and show redirects of a URL.
#!/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