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

255
Vistas
Node.js Cheerio Live Update/Instant Refresh page on every HTML body change

I am using Axios and cheerio to scrape the cricket score website and convert its data to JSON format. But the problem is that scores and other information are not updating instantly on my API response. I want to have kind of useEffect (I know, it's React Hook and don't work in Express) functionality in my express server so that whenever the score changes on the main website, my server re-scrapes the page and show updated data.

axios(link).then(response => {
        const html = response.data
        const $ = cheerio.load(html)
        const score = []

        $('.scorecard-container', html).each(function(){
            const title = $(this).text()
            const url = link + $(this).find('a').attr('href')
            score.push({
                id: score.length + 1,
                title,
                url
            })
        })
        res.json(score)
    }).catch(err => {res.send('Something went wrong'); console.log(err)})

Thanks in Advance :)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

example express endpoint

get("/stats", async (req, res) => {
  let { data } = await axios.get(someUrl)
  let $ = cheerio.load(data)
  res.json({
    title: $('title').text()
  })
})

in react

useEffect(() => {
  fetch("/stats").then(r=> r.json().then(data => setStats(data)))
}, [])
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