danmactough / node-feedparser

Robust RSS, Atom, and RDF feed parsing in Node.js
Other
1.97k stars 192 forks source link

Example not updating (new elements in the feed are ignored) #162

Closed LucasSeveryn closed 6 years ago

LucasSeveryn commented 8 years ago

In the readme we have the example, is there a reason why it reads the latest update to the feed but then doesn't pick up any subsequent ones?

var FeedParser = require('feedparser')
  , request = require('request');

var req = request('http://somefeedurl.xml')
  , feedparser = new FeedParser([options]);

req.on('error', function (error) {
  // handle any request errors
});
req.on('response', function (res) {
  var stream = this;

  if (res.statusCode != 200) return this.emit('error', new Error('Bad status code'));

  stream.pipe(feedparser);
});

feedparser.on('error', function(error) {
  // always handle errors
});
feedparser.on('readable', function() {
  // This is where the action is!
  var stream = this
    , meta = this.meta // **NOTE** the "meta" is always available in the context of the feedparser instance
    , item;

  while (item = stream.read()) {
    console.log(item);
  }
});
danmactough commented 8 years ago

That will console.log all the items in the feed. Are you referring to polling the feed for updates?