1
在Cheerio中,如何只獲取當前節點的文本?獲取當前節點的文本
var cheerio = require('cheerio')
const htmlString = '<div>hello<span>world</span></div>'
$ = cheerio.load(htmlString, { ignoreWhitespace: true })
console.log($('div').text()) //helloworld
console.log($('span').text()) //world
你怎麼得到hello
?
見https://github.com/cheeriojs/cheerio/issues/146參考 – Kevin