Puppeteer how to get all image response from website with lazy loading

Viewed 91

It executes concurrently while the page is loading page.on('response', async response => {});

I use this to scroll the page, but it does it after the page has finished loading

async function autoScroll(page){
    await page.evaluate(async () => {
        await new Promise((resolve, reject) => {
            var totalHeight = 0;
            var distance = 500;
            var timer = setInterval(() => {
                var scrollHeight = document.body.scrollHeight;
                window.scrollBy(0, distance);
                totalHeight += distance;

                if(totalHeight >= scrollHeight){
                    clearInterval(timer);
                    resolve();
                }
            }, 100);
        });
    });
}

Lazy loading demo: https://davidwalsh.name/demo/lazyload-2.0.php

Demo

Does anyone have a way?

0 Answers
Related