chapter无法使用find方法筛选strong标签取不到text的值,请大神指点
var http = require('http') var cheerio = require('cheerio') var url = 'http://www.imooc.com/learn/348' function fliter(html){ var $ = cheerio.load(html) var chapters = $('.chapter') console(chapters[0].find('strong').text()) } http.get(url,function(res){ var html = '' res.on('data',function(data){ html +=data }) res.on('end',function(){ fliter(html) }) }).on('error',function(){ console.log('错误!!!') })
报错如下: