Is there a way to read from an RSS feed using Node.js, possibly, in Real-time?
Thanks
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
);
}
});
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.