Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

229
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda