Skip to content

Instantly share code, notes, and snippets.

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"]
resp = requests.get(new_url, allow_redirects = False)
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.