Last active
January 12, 2018 15:11
-
-
Save jdiez17/db4f87fc4dad7b0d855017358bf426ae to your computer and use it in GitHub Desktop.
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 | |
import re | |
url = "https://permanent-redirect.xyz/pages/1515222320" | |
body = None | |
while body is None or "301 Permanent Redirect" in body: | |
body = requests.get(url).text | |
if "500 Internal Server Error" in body: | |
print("Internal server error, continuing") | |
body = None | |
continue | |
m = re.search("permanent-redirect\.xyz\/pages\/([0-9]+)", body) | |
url = "https://" + m.group(0) | |
m = re.findall('alt="(\d)"', body) | |
counter = ''.join(m) | |
print(f"Counter is {counter}, new URL is {url}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the fact that the last part of the redirect link is the unix/epoch time to get to the art as well:
https://gist.github.com/mauritsvdvijgh/25ec10c638c4f1b1ff52481ef479d756