1
我試圖操縱木偶的人,這是你可以在 https://try-puppeteer.appspot.com/操縱木偶page.evaluate querySelectorAll返回空對象
問題運行示例代碼此代碼返回空對象的數組
[{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{ },{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}, {},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{} ,{},{},{},{},{},{},{}]
我在做錯誤?
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://reddit.com/');
let list = await page.evaluate(() => {
return Promise.resolve(Array.from(document.querySelectorAll('.title')));
});
console.log(JSON.stringify(list))
await browser.close();