Skip to content

Instantly share code, notes, and snippets.

@DissectMalware
Last active December 11, 2021 18:08
Show Gist options
  • Save DissectMalware/b6de41f29bdbc72b9dc0e72c786b0d7c to your computer and use it in GitHub Desktop.
Save DissectMalware/b6de41f29bdbc72b9dc0e72c786b0d7c to your computer and use it in GitHub Desktop.
Obtain url redirects with python
import requests
def get_redirect_urls(url):
result = []
resp = requests.get(url)
for i in resp.history:
result.append(i.url)
result.append(resp.url)
return result
#example
get_redirect_urls('http://bit.ly/e0Mw9w')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment