Crates.io | feed-rs |
lib.rs | feed-rs |
version | |
source | src |
created_at | 2017-06-15 06:45:16.71733 |
updated_at | 2024-12-08 04:01:31.746116 |
description | A feed parser that handles Atom, RSS 2.0, RSS 1.0, RSS 0.x and JSON Feed |
homepage | https://github.com/feed-rs/feed-rs |
repository | https://github.com/feed-rs/feed-rs.git |
max_upload_size | |
id | 19044 |
Cargo.toml error: | TOML parse error at line 25, column 1 | 25 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Library for parsing various forms of feeds such as Atom, RSS and JSON Feed. It also supports extensions such as iTunes, Dublin Core and Media RSS and serialisation/deserialisation via serde.
Add the dependency to your Cargo.toml
.
[dependencies]
feed-rs = "2.3.0"
To automatically sanitize parsed HTML content, use the sanitize
feature. Note
that fields with a media type of text/plain
will not be sanitized, to avoid
potential data loss and should be sanitized by the consumer of the feed if
rendered as HTML.
[dependencies]
feed-rs = { version = "2.2.1", features = ["sanitize"] }
A feed can be parsed from any object that implements the Read
trait.
use feed_rs::parser;
let xml = r#"
<feed>
<title type="text">sample feed</title>
<updated>2005-07-31T12:29:29Z</updated>
<id>feed1</id>
<entry>
<title>sample entry</title>
<id>entry1</id>
</entry>
</feed>
"#;
let feed = parser::parse(xml.as_bytes()).unwrap();
The parser will automatically detect XML vs. JSON so parsing JSON Feed content works the same way.
use feed_rs::parser;
let json = r#"
{
"version": "https://jsonfeed.org/version/1",
"title": "JSON Feed",
"description": "JSON Feed is a pragmatic syndication format for blogs, microblog s, and other time-based content.",
"home_page_url": "https://jsonfeed.org/",
"feed_url": "https://jsonfeed.org/feed.json",
"author": {
"name": "Brent Simmons and Manton Reece",
"url": "https://jsonfeed.org/"
},
"items": [
{
"title": "Announcing JSON Feed",
"date_published": "2017-05-17T08:02:12-07:00",
"id": "https://jsonfeed.org/2017/05/17/announcing_json_feed",
"url": "https://jsonfeed.org/2017/05/17/announcing_json_feed",
"content_html": "<p>We — Manton Reece and Brent Simmons — have noticed that JSON...</p>"
}
]
}"#;
let feed = parser::parse(json.as_bytes()).unwrap();
MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
Any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions.
This crate was originally created by Hiroki Kumamoto. I would like to pay my respects to Kumamoto-san, and say thank you for allowing me to take over the crate and its ongoing maintenance. ありがとう ございます!