Using cheerio to select text from paragraph tags (<p>) with no class
<p>I'm using cheerio (cheeriojs) to scrape content from a site which has the following HTML layout.</p>
<pre><code>&lt;div class=&quot;foo&quot;&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do  eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
&lt;br&gt;&lt;br&gt;
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
&lt;br&gt;&lt;br&gt;
&lt;/p&gt;
</code></pre>
<p>I'm able to reach this content using the each function in the docs (<a href="https://github.com/cheeriojs/cheerio#each-functionindex-element-" rel="nofollow noreferrer">here</a>) by traversing the DOM looking for &quot;.foo&quot; class like so.</p>
<pre><code>$('.foo').each(function(i, el){
 //Do something...
 $(this).next().next().text()
 }
</code></pre>
<p>From here I'm able to simply convert this content to a string, and retrieve as I wish, however the text comes back in one unformatted long string. (i.e. a long essay of paragraphs without spacing between the respective paragraphs). Is there a way, trick I could retrieve the content whilst keeping the formatted content?</p>
<p>I've attempted the following;</p>
<pre><code>      `var fruits = [];
        
        $('.foo').each(function(i, el){
            fruits[i] = $(this).next().next().text();
      }` 
</code></pre>
<p>As a way to get the current tag and  push it to an array, however this isn't much different from my earlier code. I'm assuming this would be possible if the <code>&lt;br&gt;</code> tags had some id or classes, however they don't. Is there a way I can directly target these (<code>&lt;br&gt;</code>) as a way to get the text, and retrieve it in proper format (i.e. with spacing between paragraphs). At this junction, I must ask those who are more familiar and experience with cheerio if what I'm trying to do in this particular cash is even feasible with cheerio? I'm open to pursuing other route, and would welcome recommendation for modules/libraries that could help make this an easier task.</p>
<p><strong><em>To recap: I want to retrieve all text between the second <code>&lt;p&gt;</code> tags, maintaining format and spacing as seen on rendered HTML.</em></strong></p>
<p>Thanks in advance.</p>