Skip to content

Instantly share code, notes, and snippets.

@asamountain
Created January 4, 2020 09:18
Show Gist options
  • Save asamountain/249f92c81c79acfee4ee1288499f1ea4 to your computer and use it in GitHub Desktop.
Save asamountain/249f92c81c79acfee4ee1288499f1ea4 to your computer and use it in GitHub Desktop.
Puppeteer auto scrolling down for infinite element( puppeteer required )
await page.evaluate(async() => {
await new Promise((resolve, reject) => {
var totalHeight = 0;
var distance = 100;
var timer = setInterval(() => {
var scrollHeight = document.body.scrollHeight;
window.scrollBy(0, distance);
totalHeight += distance;
if (totalHeight >= scrollHeight) {
clearInterval(timer);
resolve();
}
}, 50);
})
})
@asamountain
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment