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

230
Visualizações
puppeteer page.evaluate returns an empty object

im trying to scrape a price element from a website using the page.evaluate method, but it allways returns {} when i console.log the result. here's the code:

const browser = await pptr.launch()
const page = await browser.newPage()
await page.goto("url")
const price = await page.evaluate(() => {
    return document.querySelector("selector")
})
console.log(price) // returns {}

I've tried using page.$(selector) too, it returns an array containing ElementHandle and bunch of other stuuf whitch i don't fully understand what they are

thanks!

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

0

You are trying to pass an element handle from the browser to your puppeteer application. To transfer data from the browser puppeteer uses JSON.stringify and the element handle gets transformed into an empty object.

You could try to pass something else back to your application like the text content of the element.

const browser = await pptr.launch()
const page = await browser.newPage()
await page.goto("url")
const price = await page.evaluate(() => {
    return document.querySelector("selector").textContent
})
console.log(price)
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