Created
January 29, 2020 21:14
A snippet to guess the shoutkey for LTI colloquiums
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 itertools | |
from typing import List, Optional | |
import requests | |
def get_url(url_base: str, xs: List[int]) -> str: | |
return url_base + "".join(chr(x + 97) for x in xs) | |
def attempt(date: str, speaker_last_name: str) -> Optional[str]: | |
url_base = f"http://aladdin3.inf.cs.cmu.edu/colcheck/?k={speaker_last_name}_{date}" | |
for n_letters in range(0, 2 + 1): | |
for xs in itertools.product(*[range(26) for _ in range(n_letters)]): | |
url = get_url(url_base, xs) | |
r = requests.get(url) | |
if b"img" in r.content: | |
return url | |
return None | |
if __name__ == '__main__': | |
date = "0124" | |
speaker_last_name = "starzl" | |
url = attempt(date, speaker_last_name) | |
if url is None: | |
print("Failed") | |
else: | |
print(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment