Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

212
Visualizações
Puppeteer crashes Chromium while scrolling Whatsapp Web

I'm trying to use Puppeteer to scroll to the last message of a Whatsapp chat so I can get the HTML of the whole convo and some scraping of that data. My current program does scroll up but crashes midway. It is a pretty large convo (>40k messages) but I wanted to know if the reason is the size or if there's something I can do to prevent this. I've tried to play with the waiting times between scrolls since I thought I was too fast but it didn't matter.

Here's my code:

const CONTACT_NAME = 'name';
const puppeteer = require('puppeteer');
const fs = require('fs/promises');

(async () => {
  const browser = await puppeteer.launch({
    defaultViewport: null,
    headless: false,
    args: ['--no-sandbox', '--disable-setuid-sandbox'],
  }); // default is true
  const page = await browser.newPage();
  await page.goto('https://web.whatsapp.com');
  await page.setViewport({
    width: 800,
    height: 800,
  });
  await page.waitForSelector(`[title="${CONTACT_NAME}"]`, { timeout: 1000000 });
  await page.click(`[title="${CONTACT_NAME}"]`);

  await page.waitForTimeout(1 * 20 * 1000);

  const scrollable_section = '_33LGR';

  function scroll() {
    return page.evaluate((selector) => {
      const scrollableSection = document.getElementsByClassName(selector)[0];
      return new Promise((resolve, reject) => {
        console.log(scrollableSection);
        let previousHeight = scrollableSection.scrollHeight;
        scrollableSection.scrollTop = 0;
        let counter = 0;

        const timer = setInterval(() => {
          const scrollHeight = scrollableSection.scrollHeight;
          console.log({ previousHeight, scrollHeight });
          if (previousHeight === scrollHeight) {
            counter++;
            if (counter === (2 * 60 * 1000) / 3000) {
              clearInterval(timer);
              resolve();
            }
          } else {
            scrollableSection.scrollTop = 0;
            previousHeight = scrollHeight;
            counter = 0;
          }
        }, 3000);
      });
    }, scrollable_section);
  }

  await scroll();

  const html = await page.content();
  await fs.writeFile('output.html', html);
  await page.screenshot({ path: 'page.png' });
  await browser.close();
})();

And here's the error message in Chromium ("Aw Snap! something went wrong while displaying this webpage. Error Code: 5.) :

Sorry it's in spanish

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda