Created
March 2, 2016 21:31
-
-
Save greinacker/063d38995f3ca228a130 to your computer and use it in GitHub Desktop.
Get redirect URLs
This file contains hidden or 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
# 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