Ai
4 Star 9 Fork 0

durban.zhang/node-rss-spider

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.js 4.83 KB
一键复制 编辑 原始数据 按行查看 历史
wenwen 提交于 2015-06-25 23:43 +08:00 . 调整抓取数据队列
var spider = require('./main');
var _ = require('lodash');
var moment = require('moment');
var PostController = require('./controller/PostController');
var NewsController = require('./controller/NewsController');
var CronJob = require('cron').CronJob;
var crypto = require('crypto');
var async = require('async');
var job = new CronJob('*/5 * * * *', function(){
async.parallel([
function(done){
/**
* 新浪 - 新闻 - http://rss.sina.com.cn/news/marquee/ddt.xml
*/
var news_url = 'http://rss.sina.com.cn/news/marquee/ddt.xml';
spider.FetchRss(news_url).then(function(data){
async.mapSeries(data,function(i,callback){
var md5 = crypto.createHash('md5');
NewsController.create({
title:i.title,
link:i.link,
date: i.date == 'Invalid Date' ? '' : moment(i.date).format('YYYY-MM-DD HH:mm:ss'),
author:i.author,
description:i.description,
guid:md5.update(i.guid).digest('hex'),
cate:'sina',
c_cate:'新闻'
},function(err){
if(err) return done(err);
callback(null,[]);
});
},function(err,res){
done(null,'sina-新闻');
});
});
},
function(done){
/**
* 新浪 - 财经 - http://rss.sina.com.cn/roll/finance/hot_roll.xml
*/
var finance_url = 'http://rss.sina.com.cn/roll/finance/hot_roll.xml';
spider.FetchRss(finance_url).then(function(data){
async.mapSeries(data,function(i,callback){
var md5 = crypto.createHash('md5');
NewsController.create({
title:i.title,
link:i.link,
date: i.date == 'Invalid Date' ? '' : moment(i.date).format('YYYY-MM-DD HH:mm:ss'),
author:i.author,
description:i.description,
guid:md5.update(i.guid).digest('hex'),
cate:'sina',
c_cate:'财经'
},function(err){
if(err) return done(err);
callback(null,[]);
});
},function(err,res){
done(null,'sina-财经');
});
});
},
function(done){
/**
* sohu 互联网 - http://rss.it.sohu.com/rss/hulianwang.xml
*/
var hulianwang_url = 'http://rss.it.sohu.com/rss/hulianwang.xml';
spider.FetchRss(hulianwang_url).then(function(data){
async.mapSeries(data,function(i,callback){
var md5 = crypto.createHash('md5');
NewsController.create({
title:i.title,
link:i.link,
date: i.date == 'Invalid Date' ? '' : moment(i.date).format('YYYY-MM-DD HH:mm:ss'),
author:i.author,
description:i.description,
guid:md5.update(i.guid).digest('hex'),
cate:'sohu',
c_cate:'互联网'
},function(err){
if(err) return done(err);
callback(null,[]);
});
},function(err,res){
done(null,'sohu-互联网');
});
});
},
function(done){
/**
* 开源项目
* @type {String}
*/
var feel_url = 'http://www.oschina.net/project/rss';
spider.FetchRss(feel_url).then(function(data){
async.mapSeries(data,function(i,callback){
var md5 = crypto.createHash('md5');
NewsController.create({
title:i.title,
link:i.link,
date: i.date == 'Invalid Date' ? '' : moment(i.date).format('YYYY-MM-DD HH:mm:ss'),
author:i.author ? i.author : '开源中国',
description:i.description,
guid:md5.update(i.guid).digest('hex'),
cate:'oschina',
c_cate:'开源项目'
},function(err){
if(err) return done(err);
callback(null,[]);
});
},function(err,res){
done(null,'oschina-开源项目');
});
});
},
function(done){
/**
* 开源新闻
* @type {String}
*/
var feel_url = 'http://www.oschina.net/news/rss';
spider.FetchRss(feel_url).then(function(data){
async.mapSeries(data,function(i,callback){
var md5 = crypto.createHash('md5');
NewsController.create({
title:i.title,
link:i.link,
date: i.date == 'Invalid Date' ? '' : moment(i.date).format('YYYY-MM-DD HH:mm:ss'),
author:i.author ? i.author : '开源中国',
description:i.description,
guid:md5.update(i.guid).digest('hex'),
cate:'oschina',
c_cate:'开源新闻'
},function(err){
if(err) return done(err);
callback(null,[]);
});
},function(err,res){
done(null,'oschina-开源新闻');
});
});
}
],function(error,result){
console.log(result);
});
},null,true);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/durban/node-rss-spider.git
git@gitee.com:durban/node-rss-spider.git
durban
node-rss-spider
node-rss-spider
master

搜索帮助