1

I am trying to loop through images in a Facebook post, but I am not quite sure how to extract the images while I'm looping, any idea how I can fix this? Thank you


(async()=>{

    const browser = await puppeteer.launch({
        headless: false,
        defaultViewport: false
    });

    const page = await browser.newPage();
    const url = `https://www.facebook.com/groups/133096796703382/permalink/5785155774830761/`;
    await page.goto(url, {"waitUntil": "networkidle2"});
    const images = await page.evaluate(()=>{

        Array.from(
            document.querySelectorAll('div[class="l9j0dhe7"] > img')
        )
    })

})();```
New coder
  • 59
  • 4
  • What do you mean by "extract the images"? Do you want their src or to write them to your local file system? There should be a `return` in front of `Array.from`, and `Array.from` should have a mapper to pull out some serializable property of the image, presumably its `src`. – ggorlen Jul 12 '22 at 14:56
  • Does this answer your question? [How can I download images on a page using puppeteer?](https://stackoverflow.com/questions/52542149/how-can-i-download-images-on-a-page-using-puppeteer) – ggorlen Jul 12 '22 at 14:57

0 Answers0