mirror of
https://gitlab.com/news-flash/article_scraper.git
synced 2025-07-07 16:15:32 +02:00
don't abort image download on failed image
This commit is contained in:
parent
f9905c8a9d
commit
481a2f41ac
1 changed files with 14 additions and 13 deletions
|
@ -53,14 +53,13 @@ impl ImageDownloader {
|
|||
evaluate_xpath!(context, xpath, node_vec);
|
||||
for mut node in node_vec {
|
||||
if let Some(url) = node.get_property("src") {
|
||||
let url = url::Url::parse(&url)
|
||||
.context(ImageDownloadErrorKind::InvalidUrl)?;
|
||||
if let Ok(url) = url::Url::parse(&url) {
|
||||
let parent_url = match self.check_image_parent(&node, &url) {
|
||||
Ok(url) => Some(url),
|
||||
Err(_) => None,
|
||||
};
|
||||
|
||||
let (small_image, big_image) = self.save_image(&url, &parent_url)?;
|
||||
if let Ok((small_image, big_image)) = self.save_image(&url, &parent_url) {
|
||||
if let Err(_) = node.set_property("src", &small_image) {
|
||||
return Err(ImageDownloadErrorKind::HtmlParse)?;
|
||||
}
|
||||
|
@ -71,6 +70,8 @@ impl ImageDownloader {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue