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.
to get parent by class:
document.getElementsByClassName('.page_content_post').innerHTML
to get parent by ID:
document.getElementById('#page_content_post').innerHTML