Package Exports
- rss-parser
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rss-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
rss-parser
Installation
You can install via npm or bower:
npm install --save rss-parser
# or
bower install --save rss-parserUsage
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)
Check out the output format in test/output/reddit.json
NodeJS
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);
})
})Web
<script src="/bower_components/rss-parser/dist/rss-parser.min.js"></script>
<script>
RSSParser.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);
})
})
</script>Redirects
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);
});Custom Fields
var options = {
customFields: {
feed: ['otherTitle', 'extendedDescription'],
item: ['coAuthor','subtitle'],
}
}
parser.parseURL('https://www.reddit.com/.rss', options, function(err, parsed) {
console.log(parsed.feed.extendedDescription);
parsed.feed.entries.forEach(function(entry) {
console.log(entry.coAuthor + ':' + entry.subtitle);
})
})Contributing
Contributions welcome!
Running Tests
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
Publishing Releases
# change version in package.json
grunt build
git commit -a -m "vX.X.X"
git tag vX.X.X
npm publish
git push --follow-tags