Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

79
Views
get stuck at scrolling the page

I try to scroll the page but the scrolling gets stuck before fetching the data.

const browser = await puppeteer.launch({ headless: false });
const [page] = await browser.pages();
// test url.
await page.goto('https://www.youtube.com/channel/UCVX_4LoUm4mdZBPdpMJkkSQ/videos', 
{ waitUntil: 'networkidle2' });
await page.setViewport({
      width: 1200,
      height: 800
    });
 await page.evaluate(async () => {
    for (var y = 0; y < window.innerHeight; y += 200) {
      window.scrollTo(0, y);
    }});

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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);
        });
    });
}

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!