Improve parsing
parent
d920f5b9b9
commit
ea754b6f3e
|
@ -20,7 +20,16 @@ use scraper::{Html, Selector};
|
|||
fn create_feed_item(item: Item, feed: &Feed, connection: &mut PgConnection) {
|
||||
let item_title = item.title.clone().unwrap();
|
||||
log::info!("Create feed item: {}", item_title);
|
||||
let frag = Html::parse_fragment(&item.content.clone().unwrap_or_default());
|
||||
|
||||
let base_content: &str = match item.content() {
|
||||
Some(c) => c,
|
||||
None => match item.description() {
|
||||
Some(c) => c,
|
||||
None => "",
|
||||
},
|
||||
};
|
||||
|
||||
let frag = Html::parse_fragment(base_content);
|
||||
let mut content = "".to_string();
|
||||
let frag_clone = frag.clone();
|
||||
frag.tree.into_iter().for_each(|node| {
|
||||
|
@ -92,7 +101,8 @@ pub async fn sync(_req: HttpRequest, data: web::Json<JsonUser>) -> impl Responde
|
|||
match result {
|
||||
Ok(channel) => {
|
||||
for item in channel.into_items() {
|
||||
create_feed_item(item, &feed, &mut connection)
|
||||
log::info!("{:?}", item);
|
||||
create_feed_item(item, &feed, &mut connection);
|
||||
}
|
||||
}
|
||||
Err(e) => log::error!("Could not get channel {}. Error: {}", feed.url, e),
|
||||
|
|
|
@ -44,3 +44,13 @@ a,
|
|||
font-size: 20px;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.feed-content p {
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.feed-content h3 {
|
||||
padding: 1em;
|
||||
font-size: 21px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue