The of this project is to convert RSS or ATOM feeds to the json-feed format.
npm install --save rss-parser
You can parse RSS from a URL, local file (NodeJS only), or a string.
parseString(xml, [options,], callback)
parseFile(filename, [options,], callback)
parseURL(url, [options,] callback)
var parser = require('rss-parser');
parser.parseURL('https://www.reddit.com/.rss', function(err, parsed) {
console.log(parsed.feed.title);
parsed.feed.entries.forEach(function(entry) {
console.log(entry.title + ':' + entry.link);
})
})
Check out output examples in test/output/reddit.json
By default, parseURL
will follow up to one redirect. You can change this
with options.maxRedirects
.
parser.parseURL('https://reddit.com/.rss', {maxRedirects: 3}, function(err, parsed) {
console.log(parsed.feed.title);
});
Contributions welcome!
The tests run the RSS parser for several sample RSS feeds in test/input
and outputs the resulting JSON into test/output
. If there are any changes to the output files the tests will fail.
To check if your changes affect the output of any test cases, run
npm test
To update the output files with your changes, run
WRITE_GOLDEN=true npm test
This project was originally forked from bobby-brennan/rss-parser. It's mostly his work, I've just changed the output to match the JSON-Feed spec.