Last active
December 11, 2021 18:08
-
-
Save DissectMalware/b6de41f29bdbc72b9dc0e72c786b0d7c to your computer and use it in GitHub Desktop.
Obtain url redirects with python
This file contains 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
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