This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a44af5
commit 83b60ea
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
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
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 |