Last active
October 14, 2022 14:49
-
-
Save mikesprague/1851fb86a577e61fbf6cf344b0d9cdfc to your computer and use it in GitHub Desktop.
Use Playwright to get the current Wordle solution
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
import puppeteer from 'puppeteer' | |
const wordleUrl = 'https://www.nytimes.com/games/wordle/index.html'; | |
const wordleLocalStorageKey = 'nyt-wordle-state'; | |
const defaultTimezone = 'America/New_York'; | |
(async () => { | |
const browser = await puppeteer.launch({ | |
args: [ | |
'--no-sandbox', | |
'--disable-setuid-sandbox', | |
'--disable-dev-shm-usage', | |
], | |
}); | |
const page = await browser.newPage({ | |
timezoneId: defaultTimezone, | |
}); | |
await page.goto(wordleUrl); | |
const gameState = await page.evaluate(() => | |
window.localStorage.getItem(wordleLocalStorageKey), | |
); | |
const { solution } = JSON.parse(gameState); | |
console.log(solution); | |
await browser.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment