如何使用cheerio(jquery)

时间:2018-07-28 22:44:15

标签: jquery html cheerio

我有以下HTML代码:

<p id="calibre_link-1" class="calibre_15">
  <a href="#calibre_link-6">
    <span class="calibre6"><span class="calibre_6"><span class="underline">
       1 Doxologia
    </span></span></span>
  </a>
</p>

<p class="calibre_7"><span class="calibre_1">Justo é o Senhor
em seus santos caminhos,</span></p>
  ....
<p class="calibre_16"><span class="calibre_1">Em verdade.
Aleluia! Aleluia!</span></p>

<blockquote class="calibre_17">
  <span class="calibre3"><span class="calibre_1">(Sl 145.17,18
  — A. Cunha)</span></span>
</blockquote>

我希望在“ p”标记内获取所有后续文本,直到出现块引用为止,但我的JS代码无法正常工作。

$('span[class="calibre_6"]').each(
  (i, el) => {
    var title = $(el).text().replace(/(\r\n|\n|\r)/g, '').replace(/ +(?= )/g, '');    

    console.log( $(el.target).find('p').text() );

    hymns[i]["title"] = title;      
  });

0 个答案:

没有答案