Skip to content

Instantly share code, notes, and snippets.

@phi-jp phi-jp/README.md
Last active Dec 27, 2018

Embed
What would you like to do?
Feedparser Usage
/*
* feed.js
*/
var FeedParser = require('feedparser');
var request = require('request');
var feed = 'http://phiary.me/rss';
var req = request(feed);
var feedparser = new FeedParser({});
var items = [];
req.on('response', function (res) {
this.pipe(feedparser);
});
feedparser.on('meta', function(meta) {
console.log('==== %s ====', meta.title);
});
feedparser.on('readable', function() {
while(item = this.read()) {
// console.log(item);
items.push(item);
}
});
feedparser.on('end', function() {
// show titles
items.forEach(function(item) {
console.log('- [' + item.title + ']' + '(' + item.link + ')');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.