'Get tag content using cheerio?
How do I get the content of an h3 tag in a list, I managed to map through the links like so:
const links = $("li > a")
.map((i, link) => link.attribs.href)
.get();
But how to do the exact same thing to get the content of something like:
<ul>
<li>
<h3>Title 1</h3>
<h3>Title 2</h3>
<h3>Title 3</h3>
</li>
</ul>
to give you an idea of what I'm looking for
const title = $("ul > li > h3")
.map((i, link) => link..)
.get()
Solution 1:[1]
In cheerio:
$('li h3').get().map(h3 => $(h3).text())
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | pguardiario |
