【发布时间】:2015-10-11 04:00:08
【问题描述】:
假设我有以下内容:
$ = cheerio.load('<html><body><ul><li>One</li><li>Two</li></body></html>');
var t = $('html').find('*').contents().filter(function() {
return this.type === 'text';
}).text();
我明白了:
OneTwo
代替:
One Two
如果我执行$('html').text(),我会得到相同的结果。所以基本上我需要的是注入像(空格)或\n这样的分隔符
注意:这不是一个 jQuery 前端问题,更像是与 Cheerio 和 HTML 解析相关的 NodeJS 后端问题。
【问题讨论】: