Skip to content

Instantly share code, notes, and snippets.

@mikesprague
Last active October 14, 2022 14:49
Show Gist options
  • Save mikesprague/1851fb86a577e61fbf6cf344b0d9cdfc to your computer and use it in GitHub Desktop.
Save mikesprague/1851fb86a577e61fbf6cf344b0d9cdfc to your computer and use it in GitHub Desktop.
Use Playwright to get the current Wordle solution
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