Unread
A package for parsing RSS 2.0, Atom 1.0. Works on both Node.js and the browser.
Features
- Small footprint
- Query attributes helper (see below)
- Cross-platform works on browser and Node.js
- TypeScript ready
Installation
npm add unread
Usage
; const res = await ;const rss = await restext; const output = await ; // We support common attributesconst feed items = output;console;console; // And you can also query custom ones (as long as we support that namespace)console; // returns first match or undefinedconsole; // Array of nodes
Supported namespaces
We support the followings XML namespaces:
http://www.w3.org/2005/Atom
(atom)http://purl.org/rss/1.0/modules/content/
(content)http://purl.org/dc/elements/1.1/
(dc)http://purl.org/dc/elements/1.0/
(dc)http://www.itunes.com/dtds/podcast-1.0.dtd
(itunes)http://search.yahoo.com/mrss/
(media)http://www.w3.org/1999/xhtml
(xhtml)http://www.w3.org/XML/1998/namespace
(xml)
Mapping
Feed
Helper | RSS | Atom |
---|---|---|
id() | /feed/id | |
title() | /rss/channel/title /rss/channel/dc:title |
/feed/title |
description() | /rss/channel/description /rss/channel/itunes:subtitle |
/feed/subtitle |
links() | /rss/channel/link | /feed/link/@href |
feedURL() | /rss/channel/atom:link[@rel="self"]/@href | /feed/link[@rel="self"]/@href |
updated() | /rss/channel/lastBuildDate /rss/channel/dc:date |
/feed/updated |
published() | /rss/channel/pubDate | |
language() | /rss/channel/language /rss/channel/dc:language |
/feed/@xml:lang |
image() | /rss/channel/image /rss/channel/itunes:image |
/feed/logo |
generator() | /rss/channel/generator | /feed/generator |
Item
Helper | RSS | Atom |
---|---|---|
id() | /rss/channel/item/guid | /feed/entry/id |
title() | /rss/channel/item/title /rss/channel/item/dc:title |
/feed/entry/title |
description() | /rss/channel/item/description /rss/channel/item/dc:description |
/feed/entry/summary |
content() | /rss/channel/item/content:encoded | /feed/entry/content |
links() | /rss/channel/item/link | /feed/entry/@href |
updated() | /rss/channel/item/dc:date | /feed/entry/updated |
published() | /rss/channel/item/pubDate /rss/channel/item/dc:date |
/feed/entry/published |
image() | /rss/channel/item/media:thumbnail | |
enclosures() | /rss/channel/item/enclosure | /feed/entry/link[@rel=”enclosure”] |
Contributors
Thanks goes to these wonderful people (emoji key):
Ahmed T. Ali 💻 📖 🚧 ⚠️ |
This project follows the all-contributors specification. Contributions of any kind welcome!
Credits
- Louis-Dominique Dubeau for their work on saxes. We use
saxes
to parse XML strings. - Dan MacTough for their work on node-feedparser. Our work is heavily inspired by
feedparser
. - mmcdole for their work on gofeed. We adopted
gofeed
fields mapping.
License
MIT © Ahmed T. Ali