0

My current code is as follows:

import puppeteer from 'puppeteer';

(async () => {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.goto('https://running2win.com');
    await page.screenshot({path: 'home.jpg', type: 'jpeg', fullPage: true});
    await page.waitForSelector('html');
    const all = await page.evaluate(() => {
        const all = document.querySelectorAll('html');
        return all;
    });
    console.log(all);
    await browser.close();
})();

I'm simply trying to troubleshoot by printing out all the html on the page. Instead it prints out:

{ '0': {} }

I suspect this may be related to the website I am trying to scrape.

I tried running the querySelector in the browser console and it functions as expected, returning all the html.

Yonahg
  • 23
  • 3
  • Try `console.log(await page.content())` to print the HTML. You can't return DOM nodes from `evaluate`. They're circular structures that only make sense in the browser. `evaluateHandle` can do it, or return the HTML or serializable data from the browser. See [Get elements from page.evaluate in Puppeteer?](https://stackoverflow.com/questions/53032903/get-elements-from-page-evaluate-in-puppeteer) – ggorlen Nov 24 '22 at 03:33

0 Answers0