I have the following structure in my HTML DOM:
<div>
<h3>Lorem ipsum dolor sit amet</h3>
<p>First paragraph</p>
<p>Second paragraph</p>
<h3>Lorem ipsum dolor sit amet</h3>
<p>Second paragraph</p>
<p>Third paragraph</p>
<p>Fourth paragraph</p>
<h3>Lorem ipsum dolor sit amet</h3>
<p>...</p>
<p>...</p>
<blockquote>...</blockquote>
</div>
In some cases, there might be one <h3> element followed by three paragraphs, while other times it could be one <h3>, three paragraphs, and a blockquote. However, there is always one heading with its siblings present.
I am looking to construct a JSON object that contains this structure while using Puppeteer, structured like this:
[
{
"h3": "heading text here",
"p": "paragraph text here",
"p": "another paragraph text here"
},
{
"h3": "heading text here",
"p": "paragraph text here",
"blockquote": "blockquote text here"
},
{
"h3": "heading text here",
"p": "...",
"p": "..."
}
]
Thank you for your help!