Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
rss-parser-browser
Advanced tools
Readme
This is a direct clone from https://github.com/bobby-brennan/rss-parser
I have removed the node dependencies so that it works with webpack in browser.
All credits should go to bobby-brennan.
You can install via npm:
npm install --save rss-parser-browser
# or
yarn add rss-parser-browser
You can parse RSS from a URL or a string.
parseString(xml, [options,], callback)
parseURL(url, [options,] callback)
Check out the full output format in test/output/reddit.json
dc:
prefix will be removed from all fieldsdc:date
and pubDate
will be available in ISO 8601 format as isoDate
author
is specified, but not dc:creator
, creator
will be set to author
(see article)var parser = require('rss-parser-browser');
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);
})
})
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);
});
If your RSS feed contains fields that aren't currently returned, you can access them using the customFields
option.
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);
})
})
To rename fields, you can pass in an array with two items, in the format [fromField, toField]
:
var options = {
customFields: {
item: [
['dc:coAuthor', 'coAuthor'],
]
}
}
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
# 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
FAQs
A simple, light-weight RSS parser for browser. Parse strings, URLs, or files and get a JS object back
The npm package rss-parser-browser receives a total of 34 weekly downloads. As such, rss-parser-browser popularity was classified as not popular.
We found that rss-parser-browser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.