rust-syndication / rss

Library for serializing the RSS web content syndication format
https://crates.io/crates/rss
Apache License 2.0
430 stars 53 forks source link

cannot parse reddit rss, `InvalidStartTag` #168

Closed dvtate closed 3 weeks ago

dvtate commented 3 weeks ago

The following code prints failed to fetch rss feed: InvalidStartTag

use std::error::Error;
use rss::Channel;
use reqwest;

async fn example_feed() -> Result<Channel, Box<dyn Error>> {
    let content = reqwest::get("https://www.reddit.com/r/funny/new.rss")
        .await?
        .bytes()
        .await?;
    let channel = Channel::read_from(&content[..])?;
    Ok(channel)
}

#[tokio::main]
async fn main() {
    match example_feed().await {
        Err(why) => println!("failed to fetch rss feed: {why:?}"),
        Ok(channel) => println!("it worked! fetched {} items!", channel.items.len()),
    }
}

The feed appears to be valid. Not sure if I'm doing something wrong here or if the parser only works on a subset of valid rss feeds.

Thanks!

dvtate commented 3 weeks ago

reading the code, it appears that feeds must start with <rss> ... which doesn't seem right.

dvtate commented 3 weeks ago

Nevermind, seems to be a new reddit policy. image

darkseid-is commented 4 days ago

rss feed from reddit is atom feed use https://github.com/rust-syndication/syndication