Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
slowpoke111 authored Sep 5, 2024
1 parent 3a44af5 commit 83b60ea
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions wordle.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 83b60ea

Please sign in to comment.