Node.js RSS module

删除回忆录丶 提交于 2019-12-03 07:33:21

问题


Is there a way to read from an RSS feed using Node.js, possibly, in Real-time?

Thanks


回答1:


Try this. It's a real-time RSS parser tutorial. Enjoy.




回答2:


try node-feedparser




回答3:


Try node-rss. It is unstable though but you should be able to use it as an example to write your own RSS parser.

/**********************************************************************
Example One:
Getting a remote RSS feed and parsing
rss.parseURL(feed_url, use_excerpt, callback);
**********************************************************************/
// URL of the feed you want to parse
var feed_url = 'http://feeds.feedburner.com/github';

var response = rss.parseURL(feed_url, function(articles) {
    sys.puts(articles.length);
    for(i=0; i<articles.length; i++) {
    sys.puts("Article: "+i+", "+
         articles[i].title+"\n"+
         articles[i].link+"\n"+
         articles[i].description+"\n"+
         articles[i].content
        );
    }
});



回答4:


Try this, this parses rss,atom and feedburner as well

https://github.com/tk120404/node-rssparser




回答5:


Not sure about realtime.. I have seen most people poll the RSS URLs using SetTimeout like the example below..

function updateFeeds() {
    // Do some work.  Possibly async
    // Call done() when finished.
}

function done() {
    setTimeout( updateFeeds, 1000 * 60 );
}

Or you could try using a Task Queue like Node-Resque.

But here are a couple of libraries that you could source from..

A simple node.js rss parser using sax-js or Node FeedParser

I found a pretty good intro to Node JS that includes a RSS parsing example.. Here

As I make my way through my project, I will update this answer with any new findings.. Hope this helped.



来源:https://stackoverflow.com/questions/5722638/node-js-rss-module

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!