Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/z0al/unread
A package for parsing RSS and Atom feeds
https://github.com/z0al/unread
atom-feed feed parser rss
Last synced: 2 months ago
JSON representation
A package for parsing RSS and Atom feeds
- Host: GitHub
- URL: https://github.com/z0al/unread
- Owner: z0al
- License: mit
- Created: 2019-02-08T14:52:15.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2023-03-27T14:05:25.000Z (over 1 year ago)
- Last Synced: 2024-10-14T08:31:13.599Z (2 months ago)
- Topics: atom-feed, feed, parser, rss
- Language: TypeScript
- Homepage:
- Size: 1.59 MB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Unread
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors) [![Build](https://img.shields.io/travis/z0al/unread.svg)](https://travis-ci.org/z0al/unread) [![Bundlephobia](https://img.shields.io/bundlephobia/minzip/unread.svg)](https://bundlephobia.com/result?p=unread)
[![NPM](https://nodei.co/npm/unread.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/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
```sh
npm add unread
```## Usage
```javascript
import { parse } from 'unread';const res = await fetch('https://overreacted.io/rss.xml');
const rss = await res.text();const output = await parse(rss);
// We support common attributes
const { feed, items } = output;
console.log(feed.title());
console.log(feed.feedLink());// And you can also query custom ones (as long as we support that namespace)
console.log(item[0].get(['author', 'dc:creator'])); // returns first match or undefined
console.log(item[0].getMany(['atom:link[ref=enclosure]'])); // 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](https://allcontributors.org/docs/en/emoji-key)):
Ahmed T. Ali
π» π π§ β οΈThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
## Credits
- [Louis-Dominique Dubeau](https://github.com/lddubeau) for their work on [saxes](https://github.com/lddubeau/saxes). We use `saxes` to parse XML strings.
- [Dan MacTough](https://github.com/danmactough) for their work on [node-feedparser](https://github.com/danmactough/node-feedparser). Our work is heavily inspired by `feedparser`.
- [mmcdole](https://github.com/mmcdole) for their work on [gofeed](https://github.com/mmcdole/gofeed). We adopted `gofeed` fields mapping.## License
MIT Β© Ahmed T. Ali