Basic fetch channel
This commit is contained in:
parent
38d1cbbd50
commit
e1cb00f0b1
4 changed files with 2156 additions and 0 deletions
|
|
@ -0,0 +1,21 @@
|
|||
use std::error::Error;
|
||||
use reqwest::{
|
||||
IntoUrl,
|
||||
Client,
|
||||
};
|
||||
use rss::Channel as RawChannel;
|
||||
|
||||
pub struct Channel {
|
||||
pub channel: rss::Channel,
|
||||
}
|
||||
|
||||
pub async fn fetch_channel<T: IntoUrl>(
|
||||
client: &Client, url: T) -> Result<Channel, Box<dyn Error>> {
|
||||
let content = client.get(url)
|
||||
.send().await?
|
||||
.bytes().await?;
|
||||
|
||||
let raw_channel = RawChannel::read_from(&content[..])?;
|
||||
println!("{}", raw_channel.title);
|
||||
Ok(Channel { channel: raw_channel })
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue