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

73
Views
¿Por qué veo caracteres de secuencia de escape en la salida de análisis de cheerio?

Adjunto a continuación es mi código: -

 app.get("/techcrunch", (req, res) => { axios("https://techcrunch.com/") .then((response) => { const html = response.data; const $ = cheerio.load(html, {decodeEntities: false }); const newsItems = []; $("h2.post-block__title").each(function () { // const title = $(this).text() const baseElement = $(this); const title = baseElement.text(); const url = baseElement.find("a").attr("href"); newsItems.push({ title, url}); }); res.send(newsItems); }) .catch((err) => console.log(err)); });

Aquí estoy tratando de analizar la fuente de la página de TechCrunch y extraer el texto almacenado en "h2.post-block__title" pero extrañamente en la cadena resultante veo caracteres de secuencia de escape como "\n", "\t" y así sucesivamente como se ve a continuación: -

 { "title": "\n\t\t\t\n\t\t\t\tThis Week in Apps: Instagram brings back the chronological feed, South Korea bans P2E games, Google looks for ecosystem integrations\t\t\t\n\t\t", "url": "https://www.bbc.comhttps://techcrunch.com/2022/01/08/this-week-in-apps-instagram-brings-back-the-chronological-feed-south-korea-bans-p2e-games-google-looks-for-ecosystem-integrations/" },

Intenté pasar {decodeEntities: false} como se ve arriba, pero aún no lo devuelve.

Una forma de resolverlo, pensé que sería ejecutar unescape() en la cadena de título devuelta por cheerio, pero desafortunadamente unescape() está obsoleto, supongo.

¿Alguna idea de lo que podría hacer? ¡¡Gracias por adelantado!!

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!