refactor: change readablity lib
This commit is contained in:
parent
c242ca8cc6
commit
0424544abf
3 changed files with 607 additions and 141 deletions
|
|
@ -1,8 +1,7 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use anyhow::Result;
|
||||
use anyhow::{Context, Result};
|
||||
use itertools::Itertools;
|
||||
use llm_readability::extractor;
|
||||
use reqwest::{Client, Url};
|
||||
use rss::Channel;
|
||||
use tokio::{task::JoinSet, time::sleep};
|
||||
|
|
@ -59,8 +58,8 @@ async fn complete(mut channel: Channel, client: &Client) -> Result<Box<Channel>>
|
|||
|
||||
async fn get_content(link: &str, client: &Client) -> Result<String> {
|
||||
let response = client.get(link).send().await?;
|
||||
let content =
|
||||
extractor::extract(&mut response.bytes().await?.as_ref(), &Url::parse(link)?)?.content;
|
||||
let mut readablity = readability_rust::Readability::new(response.text().await?.as_ref(), None)?;
|
||||
let content = readablity.parse().context("readablity parse error")?.content.context("readablity no content")?;
|
||||
Ok(content)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue