【发布时间】:2016-06-10 22:24:46
【问题描述】:
此 Meteor 服务器代码使用cheerio 并尝试提取文本“John”,我尝试了以下几种不同的方法均无济于事。console.log(e.next.children.eq(1).text());
console.log(e.next.children.last().text());
console.log(e.next.contents().last().text());
cheerio 怎么做?谢谢
ResObj.$("table").contents().filter(function() {
return this.nodeType == 8;
}).each(function(i, e) {
if (e.nodeValue.trim() == 'CONTACTS') {
console.log(e.next.contents('td').eq(1).text()); //<----------
console.log(e.nextSibling.nodeType); // returns 3
}
});
<!-- CONTACTS -->
<tr>
<td class="label" valign="top" align="right" style="white-space:nowrap">
Names of people:
</td>
<td class="displayValue" valign="top">
John
</td>
</tr>
【问题讨论】: