hellokitty111
7/8/2014 - 1:08 AM

获取伯乐在线 在线视频链接以及教学视频介绍

获取伯乐在线 在线视频链接以及教学视频介绍

// url :
// page1   http://blog.jobbole.com/category/online-courses/
// page2   http://blog.jobbole.com/category/online-courses/page/2/
var request = require("request");
var cheerio = require("cheerio");
var urls = ["http://blog.jobbole.com/category/online-courses/","http://blog.jobbole.com/category/online-courses/page/2/"];

var callback = function(error,response,body){
  if(!error && response.statusCode == 200 || response.statusCode == 500){
  var $ = cheerio.load(body);
  $('div#archive.grid-8 div.post-meta').each(function(){
    console.log("%s,%s,%s",$(this).find('a.meta-title').text(),$(this).find('a').attr("href"),$(this).find("span.excerpt").text());
  });
}
};

for(i in urls){
  request(urls[i],callback);
};