Skip to content

Instantly share code, notes, and snippets.

@jdiez17
Last active January 12, 2018 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdiez17/db4f87fc4dad7b0d855017358bf426ae to your computer and use it in GitHub Desktop.
Save jdiez17/db4f87fc4dad7b0d855017358bf426ae to your computer and use it in GitHub Desktop.
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}")
@mauritsvdvijgh
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment