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

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

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 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