From 83b60ea469f9870651fc2f1f9887fda0e0092fdb Mon Sep 17 00:00:00 2001 From: slowpoke111 <110692534+slowpoke111@users.noreply.github.com> Date: Thu, 5 Sep 2024 16:32:55 -0400 Subject: [PATCH] Add files via upload --- wordle.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 wordle.py diff --git a/wordle.py b/wordle.py new file mode 100644 index 0000000..cc77406 --- /dev/null +++ b/wordle.py @@ -0,0 +1,34 @@ +import aiohttp +import asyncio +from datetime import datetime, timedelta + + +async def fetch_wordle_solution(future=1): + today = datetime.now() + target_date = today + timedelta(days=future) + date_str = target_date.strftime("%Y-%m-%d") + + url = f"https://www.nytimes.com/svc/wordle/v2/{date_str}.json" + + try: + async with aiohttp.ClientSession() as session: + async with session.get(url) as response: + data = await response.json() + return data["solution"] + except Exception as error: + print("Error fetching the Wordle solution:", error) + raise Exception(error) + + +async def main(future=1): + word = await fetch_wordle_solution(future=future) + print(word) + + +if __name__ == "__main__": + for i in range(-5,50): + try: + print(str(i) + ": ", end="") + asyncio.run(main(future=i)) + except Exception: + break