filipedeschamps / rss-feed-emitter

Super RSS News Feed aggregator written in Node.js and ES6

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

invalid_feed: Cannot parse${this.url} XML

dytra opened this issue · comments

commented

Hello I'm trying to listen to this specific feed url : https://cointelegraph.com/rss

The first try it has no problem

But after some view minutes, it seems the website have some sort off protection

That's ok for me, but the problem is the library throws error that makes my app crashed

Error Message:

/home/dytra/home/coinblitz/coinalert/node_modules/rss-feed-emitter/src/Feed.js:162
        this.handleError(new FeedError(`Cannot parse ${this.url} XML`, 'invalid_feed', this.url));
                         ^
invalid_feed: Cannot parse https://cointelegraph.com/rss XML
    at FeedParser.<anonymous> (/home/dytra/home/coinblitz/coinalert/node_modules/rss-feed-emitter/src/Feed.js:162:26)
    at FeedParser.emit (node:events:520:28)
    at FeedParser.emit (node:domain:475:12)
    at done (/home/dytra/home/coinblitz/coinalert/node_modules/readable-stream/lib/_stream_transform.js:195:19)
    at /home/dytra/home/coinblitz/coinalert/node_modules/readable-stream/lib/_stream_transform.js:136:9
    at FeedParser._flush (/home/dytra/home/coinblitz/coinalert/node_modules/feedparser/main.js:1070:5)
    at FeedParser.<anonymous> (/home/dytra/home/coinblitz/coinalert/node_modules/readable-stream/lib/_stream_transform.js:135:12)
    at Object.onceWrapper (node:events:639:28)
    at FeedParser.emit (node:events:520:28)
    at FeedParser.emit (node:domain:475:12) {
  feed: 'https://cointelegraph.com/rss'
}

Here's my code

const RssFeedEmitter = require('rss-feed-emitter');
const feeder = new RssFeedEmitter({ userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0' });

		feeder.add({
			url: [
                                'https://decrypt.co/feed',
				'https://cointelegraph.com/rss',
			],
			refresh: 5000
		});

		feeder.on('new-item', function (item) {
			console.log(item);

		})

I would be happy if the library just continue to fetch the rss, and if there's an error occured, just ignore the feed url and just continue the loop without crashing my app

commented

never mind, my bad I didn't read the full documentation

I can use the feeder.on('error', console.error); event

commented

yeah, you need to handle errors. have a great day!

commented

you'll probably want to on error remove the url that errors. as you can see, there's a "feed" field on the error to make that easier for you.