async def request_to(url: str) -> response_profile: await asyncio.sleep(1) async with aiohttp.ClientSession(cookie_jar=cookie_jar) as session: try: async with session.get(url, timeout=timeout) as response: print(response) yellow("Session : " + str([c for c in session.cookie_jar])) if response.url.host not in URL: # website page is returned not API (api.www.root-me.org / www.root-me.org) return None # purple(f'[{response.status}] {url}') if response.status == 200: return await response.json() elif response.status == 401: if await get_status() == 200: purple(f'{url} -> probably a premium challenge') return None await get_cookies() return await request_to(url) elif response.status == 429: # Too Many requests return await request_to(url) else: return None except asyncio.TimeoutError: return await request_to(url)
def display(part: str) -> None: lines = part.split('\n') for line in lines: yellow(line)