简体   繁体   中英

Code running in Chrome Console does not work in puppeteer

I'm setting up Facebook Scraper with puppeteer but I have checked this code in Chrome console and it works.

I have listed the class, I need to get the id of the class I have listed.

Chrome Console query Selector

Puppeteer Code

Did you try the following?

let post_id = await postElement.evaluate(() => {
    return {
        document.querySelector('div[class="_5pcb _4b01 _2q8l"]').id,
    }
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM