-
-
Save jackfranklin/06bed136fdb22419cb7a8a9a4d4ef32f to your computer and use it in GitHub Desktop.
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
const puppeteer = require('puppeteer') | |
async function run() { | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
await page.goto('https://example.com'); | |
const stuff = await page.$('div') | |
if (!stuff) { | |
throw new Error('no stuff') | |
} | |
const foo = await stuff.evaluate((elem) => { | |
const x = elem.getAttribute('data-x') || '0' | |
return window.parseInt(x); | |
}); | |
console.log(foo) | |
} | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment