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

105
Views
Cheerio está extrayendo texto vacío y href indefinido

Estoy tratando de obtener las noticias deportivas de The Guardian UK usando Cheerio. Pero, todo lo que obtengo es una cadena vacía de la etiqueta 'a' y 'indefinido' para el atributo 'href'.

 const axios = require("axios") const cheerio = require("cheerio") const url = "https://www.theguardian.com/uk/sport" const news = [] function getSportsNews() { axios.get(url).then((response) => { const html = response.data const $ = cheerio.load(html) $('a', html).each(() => { const title = $(this).text() const link = $(this).attr('href') news.push({ title, link }) console.log(news) }) }) } getSportsNews()

Intenté agregar un agente de usuario falso al encabezado de axios , no funcionó.

Sin embargo, imprimió los textos cuando ejecuté console.log($('a').text()) fuera del ciclo para verificar si realmente estaba recuperando algo. Pero en eso each bloque está volviendo todo vacío.

about 4 years ago · Juan Pablo Isaza
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!