Skip to content

Instantly share code, notes, and snippets.

@greinacker
Created March 2, 2016 21:31
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 greinacker/063d38995f3ca228a130 to your computer and use it in GitHub Desktop.
Save greinacker/063d38995f3ca228a130 to your computer and use it in GitHub Desktop.
Get redirect URLs
# coding: utf-8
import sys
import clipboard
import requests
import webbrowser
url = sys.argv[1]
redir_urls = []
resp = requests.get(url, allow_redirects = False)
while resp.status_code == 301 or resp.status_code == 302:
new_url = resp.headers["location"]
redir_urls.append(new_url)
resp = requests.get(new_url, allow_redirects = False)
clipboard.set(",".join(redir_urls))
webbrowser.open("workflow://")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment