Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.