import requests from models.xkcdComic import Comic import json class ProgrammerExcuses: def __init__(self) -> None: self.__url = "http://programmingexcuses.com" def getExcuse(self): page = requests.get(url=self.__url) content = page.content.decode().split("\n") for html in content: if 'href="/"' in html: start_index = html.find('3;">') end_index = html.find("") return html[start_index+4:end_index] class XKCD: def __init__(self) -> None: self.__url = "https://xkcd.com" self.__api = "info.0.json" def getRandomComic(self): pass def getLastComic(self): response = requests.api.get(f"{self.__url}/{self.__api}") return Comic(json.loads(response.text))