UNPKG

scrapper-tools

Version:

Its in development but I use it in all my web automation project.

19 lines (17 loc) 474 B
export default async function autoScroll(page) { 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() } }, 30) }) }) }