Puppeteer: Getting Html From Nodelist?
I'm getting a list of 30 items from the code: const boxes = await page.evaluate(() => { return document.querySelectorAll('DIV.a-row.dealContainer.dealTile') }) console.log(
Solution 1:
There are multiple ways to do this:
- Use
page.$$eval
to execute the selector and return the result in one step. - Use
page.evaluate
to get the attributes after querying the elements.
Code sample for page.$$eval
const htmls = await page.$$eval('selector', el => el.innerHTML);
Code sample for page.evaluate
const singleBox = boxes[0];
const html = await page.evaluate(el => el.innerHTML, singleBox);
Post a Comment for "Puppeteer: Getting Html From Nodelist?"