https://github.com/Ranchero-Software/RSParser
Parser for RSS, Atom, JSON Feed, RSS-inJSON, OPML, and HTML.
https://github.com/Ranchero-Software/RSParser
Last synced: about 1 year ago
JSON representation
Parser for RSS, Atom, JSON Feed, RSS-inJSON, OPML, and HTML.
- Host: GitHub
- URL: https://github.com/Ranchero-Software/RSParser
- Owner: Ranchero-Software
- License: mit
- Archived: true
- Created: 2017-12-27T00:36:52.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-04-08T02:44:17.000Z (about 2 years ago)
- Last Synced: 2025-04-03T02:18:32.509Z (about 1 year ago)
- Language: HTML
- Homepage: http://inessential.com/2017/12/26/evergreens_parser_as_separate_open_sour
- Size: 1.35 MB
- Stars: 365
- Watchers: 10
- Forks: 39
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RSParser
This framework was developed for [NetNewsWire](https://github.com/brentsimmons/NetNewsWire) and is made available here for developers who just need the parsing code. It has no dependencies that aren’t provided by the system.
_Update 6 Feb. 2018_: RSParser is now a CocoaPod, with the much-appreciated help of [Silver Fox](https://github.com/dcilia). (We _think_ it worked, anyway. Looked like it did.)
## What’s inside
This framework includes parsers for:
* [RSS](http://cyber.harvard.edu/rss/rss.html), [Atom](https://tools.ietf.org/html/rfc4287), [JSON Feed](https://jsonfeed.org/), and [RSS-in-JSON](https://github.com/scripting/Scripting-News/blob/master/rss-in-json/README.md)
* [OPML](http://dev.opml.org/)
* Internet dates
* HTML metadata and links
* HTML entities
It also includes Objective-C wrappers for libXML2’s XML SAX and HTML SAX parsers. You can write your own parsers on top of these.
This framework builds for macOS. It *could* be made to build for iOS also, but I haven’t gotten around to it yet.
## How to parse feeds
To get the type of a feed, even with partial data, call `FeedParser.feedType(parserData)`, which will return a `FeedType`.
To parse a feed, call `FeedParser.parse(parserData)`, which will return a [ParsedFeed](Feeds/ParsedFeed.swift). Also see related structs: `ParsedAuthor`, `ParsedItem`, `ParsedAttachment`, and `ParsedHub`.
You do *not* need to know the type of feed when calling `FeedParser.parse` — it will figure it out and use the correct concrete parser.
However, if you do want to use a concrete parser directly, see [RSSInJSONParser](Feeds/JSON/RSSInJSONParser.swift), [JSONFeedParser](Feeds/JSON/JSONFeedParser.swift), [RSSParser](Feeds/XML/RSSParser.swift), and [AtomParser](Feeds/XML/AtomParser.swift).
(Note: if you want to write a feed reader app, please do! You have my blessing and encouragement. Let me know when it’s shipping so I can check it out.)
## How to parse OPML
Call `+[RSOPMLParser parseOPMLWithParserData:error:]`, which returns an `RSOPMLDocument`. See related objects: `RSOPMLItem`, `RSOPMLAttributes`, `RSOPMLFeedSpecifier`, and `RSOPMLError`.
## How to parse dates
Call `RSDateWithString` or `RSDateWithBytes` (see `RSDateParser`). These handle the common internet date formats. You don’t need to know which format.
## How to parse HTML