1
0
Fork 0
mirror of https://gitlab.com/news-flash/article_scraper.git synced 2025-07-07 16:15:32 +02:00
This commit is contained in:
Jan Lukas Gernert 2022-12-11 16:19:49 +01:00
parent 22e98fdab7
commit dc1bf2ef0c

View file

@ -356,19 +356,29 @@ impl FullTextParser {
}
fn check_for_thumbnail(context: &Context, article: &mut Article) {
if let Some(thumb) = Self::get_attribute(context, "//meta[contains(@name, 'twitter:image')]", "content").ok() {
if let Some(thumb) = Self::get_attribute(
context,
"//meta[contains(@name, 'twitter:image')]",
"content",
)
.ok()
{
article.thumbnail_url = Some(thumb);
return
return;
}
if let Some(thumb) = Self::get_attribute(context, "//meta[contains(@name, 'og:image')]", "content").ok() {
if let Some(thumb) =
Self::get_attribute(context, "//meta[contains(@name, 'og:image')]", "content").ok()
{
article.thumbnail_url = Some(thumb);
return
return;
}
if let Some(thumb) = Self::get_attribute(context, "//link[contains(@rel, 'image_src')]", "href").ok() {
if let Some(thumb) =
Self::get_attribute(context, "//link[contains(@rel, 'image_src')]", "href").ok()
{
article.thumbnail_url = Some(thumb);
return
return;
}
}