Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!