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

157
Visualizações
Puppeteer page's content when I pass it to another function vanishes

I'm using Puppeteer to web scrap my website. I'm using await page.content() and console logging it and I'm getting the content in the logs but when I pass page as an argument to another javascript function. The await page.content() is null. Nothing is present in the content even though I can still see the content in the browser. I have no idea why this is happening, I did literally the same things for other url of the same website but they are working fine. Only in this case, the await page.content() is returning null. I know that I can pass await page.content() as an argument directly but that won't suffice because I have conditions when to call this, otherwise server load would be high.

func1(){
   let a = await page.content()
   console.log(a) // works fine and prints the html
}

func2(){
 func3(page);
}

func3(page){
 let c = await page.content()
 console.log(c);
 //Prints nothing
}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Before func3 add the keyword async. Later, write:

await func3(page)
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