Skip to content

Instantly share code, notes, and snippets.

@syxolk
Last active February 14, 2016 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syxolk/540e329f287624c9ddaf to your computer and use it in GitHub Desktop.
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.
#!/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