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

177
Views
Cómo consultar a Cheerio para la salida html, incluidas las etiquetas del selector

Si usa $("body").html() , cheerio devuelve el html dentro de las etiquetas del cuerpo. ¿Cómo puedo consultar a Cheerio por el contenido del body , incluidas las etiquetas del body de apertura y cierre?

Tomemos por ejemplo un archivo como este:

 <body class="body"> <div> <h1>Foo Bar</h1> </div> </body> <style> .body { margin: 0; } </style>

El siguiente código generará el contenido html del body . La salida no incluirá las etiquetas <body> , que es lo que quiero lograr

 const cheerio = require("cheerio"); const $ = cheerio.load(text); const body = $("body").html(); console.log(body); // <div> // <h1>Foo Bar</h1> // </div>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use $.html("body") en lugar de $("body").html() .

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!