Created
January 4, 2020 09:18
-
-
Save asamountain/249f92c81c79acfee4ee1288499f1ea4 to your computer and use it in GitHub Desktop.
Puppeteer auto scrolling down for infinite element( puppeteer required )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
found from here.