master
Mathias Rothenhaeusler 2022-11-17 19:05:27 +01:00
commit 571be93ce1
4 changed files with 1257 additions and 0 deletions

1
.gitignore vendored 100644
View File

@ -0,0 +1 @@
/target

1219
Cargo.lock generated 100644

File diff suppressed because it is too large Load Diff

11
Cargo.toml 100644
View File

@ -0,0 +1,11 @@
[package]
name = "rss-reader"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
reqwest = { version = "0.11", features = ["json"] }
tokio = { version = "1", features = ["full"] }
rss = { version = "2.0.1" }

26
src/main.rs 100644
View File

@ -0,0 +1,26 @@
use std::error::Error;
use rss::Channel;
async fn example_feed() -> Result<Channel, Box<dyn Error>> {
let content = reqwest::get("https://www.heise.de/rss/heise.rdf")
.await?
.bytes()
.await?;
println!("{}", String::from("reading done"));
let channel = Channel::read_from(&content[..])?;
Ok(channel)
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let channel: Channel = example_feed().await?;
println!("{:?}", channel);
for item in channel.items {
println!("{}", item.content.unwrap());
}
println!("{}", String::from("test"));
Ok(())
}