Closed Ryu945 closed 7 years ago
Any feed in particular? Do you have sample code? Which node/feedparser versions?
It is happening on all feeds I have tried. I used npm install feedparser
so I assume I installed 2.1.0 . My code looks like this:
var req = request("I put rss url in here")
var feedparser = new FeedParser();
req.on('error', function (error) {
// handle any request errors
});
req.on('response', function (res) {
var stream = this; // `this` is `req`, which is a stream
if (res.statusCode !== 200) {
this.emit('error', new Error('Bad status code'));
} else {
stream.pipe(feedparser);
}
});
feedparser.on('error', function (error) {
// always handle errors
});
feedparser.on('readable', function () {
// This is where the action is!
var stream = this; // `this` is `feedparser`, which is a stream
var meta = this.meta; // **NOTE** the "meta" is always available in the context of the feedparser instance
var articles;
//var item;
//var articles = item;
while (articles = stream.read()) {
console.log(articles);
//console.log(articles.pubDate);
}
});```
var a=[]; . . feedparser.on('readable', function () {var i;while(i=this.read())a.push(i); }) .on('end',function(){ console.log('parseUrl done length= ',+a.length);});
Changed your code to something like this and works fine.
thank you @rdbcci 🙏
I am only getting the last article of the RSS feed. I looked through some of your examples and see nothing about how to get the entire RSS list.