Selecting Href Attributers With Puppeteer
I am trying to extract a few urls from this page with Puppeteer. However all my script is returning is undefined const puppeteer = require('puppeteer');  async function run() {
Solution 1:
Puppeteer cannot return non-serialisable value from evaluate statement (see this issue and the following PR)
One way to solve this would be:
let projects = await page.evaluate((sel) => {
        returndocument.getElementsByClassName(sel)[0].href;
    }, 'homepage-project-image');
Remember that document.getElementsByClassName returns HTMLCollection, so if you want to iterate over the results you need something like:
let projects = await page.evaluate((sel) => {
            returnArray.from(document.getElementsByClassName(sel)).map(node => node.href);
        }, 'homepage-project-image');
Post a Comment for "Selecting Href Attributers With Puppeteer"