nodejs学习初体验(4)小爬虫
var http = require('http')
var url = 'http://www.imooc.com/learn/348'
var cheerio = require('cheerio')
http.get(url,function(res){
var html = ''
res.on('data',function(data){
html += data
})
res.on('end',function(){
console.log(html)//打印HTML
// filterChapters(html)
})
}).on('error',function(){
console.log("获取失败")
})
// //安装模块 npm install cheerio
// function filterChapters(html){
// var $ = cheerio.load(html)
// var chapters = $('.learnchapter')
// }
本站文章如未注明出处均为原创,转载请注明出处,如有侵权请邮件联系站长。