trying capturing all the <a>
in a page
the console.log returns undefined, but i can't understand why
is this const anchors = Array.from(document.querySelectorAll(sel));
correct?
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
headless: false,
userDataDir: "C:\Users\johndoe\AppData\Local\Google\Chrome\User Data\Default"
});
const page = await browser.newPage();
await page.setViewport({
width: 1920,
height: 1080,
deviceScaleFactor: 1,
});
await page.goto('https://www.facebook.com/groups/632312010245152/members');
//https://github.com/puppeteer/puppeteer/blob/main/examples/search.js
let membri = await page.evaluate((sel) => {
const anchors = Array.from(document.querySelectorAll(sel));
return anchors;
}, 'a');
console.log(membri);
})();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…