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

144
Views
Get all content as string inside div

I need to get all content inside an HTML element, including all child nodes and grandchild nodes and their content as if it was a string. This is my expected output:

<div class="images"><div class="img_100"><a class="img a" legenda="" target="" style=""><img src="/img/site/570/b/random_image.jpg" alt="Lorem ipsum - dolor sit amet" class="portrait"></a></div></div>

I am currently using JS with puppeteer to scrape the page I need, but I need all the HTML as string to format some content and I don't know how to get this the way I want.

I also used this query document.querySelectorAll(".page_content_post") to get the parent element I want the content and child/grandchild nodes from.

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

to get parent by class:

document.getElementsByClassName('.page_content_post').innerHTML

to get parent by ID:

document.getElementById('#page_content_post').innerHTML
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!