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

345
Visualizações
TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received Promise { <pending> }

I'm getting this error while I'm trying to scrape prnt.sc, and I don't understand why.

I think setInterval() is giving me problems.

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received Promise { }

const puppeteer = require("puppeteer");
const select = require('puppeteer-select');

async function llamar() {

  const browser = await puppeteer.launch({
    headless: true
  });

  var text = "";
  var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

  for (var i = 0; i < 6; i++)
    text += "https://prnt.sc/" + possible.charAt(Math.floor(Math.random() * possible.length));
  console.log(text)


  const page = await browser.newPage();
  path = Math.random()
  await page.goto(text)
  const element = await select(page).getElement('button:contains(AGREE)');
  await element.click()
  await page.screenshot({
    path: path + '.jpg'
  })

  await browser.close();
}

setInterval(llamar(), 2000);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Indeed, in setInterval, you are supposed to give a function, not execute one.

llamar() is executing the function.

Try this:

setInterval(llamar, 2000);
about 4 years ago · Juan Pablo Isaza Relatório
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