var http = require('http');
var cheerio = require('cheerio');
var url = 'http://www.link-nemo.com/Cynthia/index.do';
function filterChapters(html){
var $ = cheerio.load(html);
var chapters = $('.article');
/**
[{
id:'',
title:''
}]
**/
var articleData = [];
chapters.each(function (item){
var chapter = $(this);
var chapterA = chapter.find('a');
var articleId = chapterA.attr('href').split('&articleid=')[1];
var articleTitle = chapterA.find('.mytitle').text();
if(articleId!=null && articleId!='' && articleTitle!=null && articleTitle != ''){
articleData.push({
id:articleId,
title:articleTitle
});
}
});
return articleData;
}
http.get(url,function (res){
var html = '';
res.on('data',function (data){
html += data;
});
res.on('end',function (){
var articles = filterChapters(html);
console.log(articles);
});
}).on('error',function (){
console.log('Error.');
});
var cheerio = require('cheerio');
var url = 'http://www.link-nemo.com/Cynthia/index.do';
function filterChapters(html){
var $ = cheerio.load(html);
var chapters = $('.article');
/**
[{
id:'',
title:''
}]
**/
var articleData = [];
chapters.each(function (item){
var chapter = $(this);
var chapterA = chapter.find('a');
var articleId = chapterA.attr('href').split('&articleid=')[1];
var articleTitle = chapterA.find('.mytitle').text();
if(articleId!=null && articleId!='' && articleTitle!=null && articleTitle != ''){
articleData.push({
id:articleId,
title:articleTitle
});
}
});
return articleData;
}
http.get(url,function (res){
var html = '';
res.on('data',function (data){
html += data;
});
res.on('end',function (){
var articles = filterChapters(html);
console.log(articles);
});
}).on('error',function (){
console.log('Error.');
});