简体   繁体   English

Node.js RSS模块

[英]Node.js RSS module

Is there a way to read from an RSS feed using Node.js, possibly, in Real-time? 有没有办法使用Node.js读取RSS提要,可能是实时的?

Thanks 谢谢

Try this . 试试这个 It's a real-time RSS parser tutorial. 这是一个实时的RSS解析器教程。 Enjoy. 请享用。

Try node-rss . 尝试node-rss It is unstable though but you should be able to use it as an example to write your own RSS parser. 它虽然不稳定,但你应该能够以它为例来编写自己的RSS解析器。

/**********************************************************************
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
        );
    }
});

Try this, this parses rss,atom and feedburner as well 试试这个,这也解析了rss,atom和feedburner

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

Not sure about realtime.. I have seen most people poll the RSS URLs using SetTimeout like the example below.. 不确定实时..我看到大多数人使用SetTimeout轮询RSS URL,如下例所示。

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 . 或者您可以尝试使用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 使用sax-jsNode FeedParser的 简单node.js rss解析器

I found a pretty good intro to Node JS that includes a RSS parsing example.. Here 我发现了一个非常好的Node JS介绍,其中包括一个RSS解析示例.. 这里

As I make my way through my project, I will update this answer with any new findings.. Hope this helped. 当我完成我的项目时,我会用任何新的发现更新这个答案。希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM