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

127
Views
Puppeteer not able to fetch data for some reason

I have created a react app that gives the following output as HTML:

import './App.css';

import Home from './Home';

function App() {
  return (
    <div className="Apps">
    <strong>"root1"</strong>
      <div className="content">
       
    <p>"root"</p>
      </div>
    </div>
  );
}

export default App;

My goal here is to basically retrieve "root1" from the <strong> tag under the Apps class. I have written the following code but it doesn't retrieve the data:

const puppeteer = require("puppeteer")
const fs = require("fs/promises")

async function start() {
  const browser = await puppeteer.launch()
  const page = await browser.newPage()
  await page.goto("https://token-pric-213.herokuapp.com/")

  const names = await page.evaluate(() => {
    return Array.from(document.querySelectorAll(".Apps strong"), els => els.map(el => el.textContent))
  })
  await fs.writeFile("names.txt", names.join("\r\n"))


  await browser.close()
}

start()

When I run the script, a new text file is created but it is empty instead of showing "root1". Can someone help me? Thanks for your time!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The correct answer was given to me by @ggorlen, it should be like this:

const puppeteer = require("puppeteer")
const fs = require("fs/promises")

async function start() {
  const browser = await puppeteer.launch()
  const page = await browser.newPage()
  await page.goto("url")

  const names = await page.evaluate(() => {
    return Array.from(document.querySelectorAll(".Apps strong"), el => el.textContent)
  })
  await fs.writeFile("names.txt", names.join("\r\n"))


  await browser.close()
}

start()

Thanks!

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!