如何在具有与cheerio相同类别的div内的html中选择html中的文本

时间:2018-10-24 21:12:27

标签: javascript node.js cheerio

我希望从第二个div中获取与chererio具有相同类(.hello)的文本的html:

<div class="hello">blablabla</div>

<div class="hello"> 
<h2 id="coucou">Coucou</h2>
blablabla 2 html to <br> 
select this is the text I want<br>
blabla bla bla bal balbal blabla
</div>

我想要的结果:

blablabla 2 html to <br> 
select this is the text I want<br>
blabla bla bla bal balbal blabla

1 个答案:

答案 0 :(得分:0)

看起来像你想要的

$('.hello + .hello').text()

在CSS中,+表示下一个兄弟姐妹。