diff --git a/README.md b/README.md index ebd04875..406d55ae 100644 --- a/README.md +++ b/README.md @@ -83,10 +83,20 @@ const browser = await puppeteer.connect({ const context = await browser.createBrowserContext(); const page = await context.newPage(); +// Dump all the links from the page. await page.goto('https://wikipedia.com/'); +const links = await page.evaluate(() => { + return Array.from(document.querySelectorAll('a')).map(row => { + return row.getAttribute('href'); + }); +}); + +console.log(links); + await page.close(); await context.close(); +await browser.disconnect(); ``` ## Build from sources