scrape image links as well (they do not need auth)

This commit is contained in:
Sebastian Hugentobler 2023-11-18 17:26:06 +01:00
parent 7649026b91
commit 79250a53d3
Signed by: shu
GPG key ID: BB32CF3CA052C2F0
2 changed files with 62 additions and 19 deletions

View file

@ -34,6 +34,7 @@ pub struct Footprint {
pub url: String,
pub date: Date,
pub page: u8,
pub images: Vec<String>,
}
const ISO8601_DATE: u128 = iso8601::Config::DEFAULT
@ -54,11 +55,23 @@ impl Footprint {
page_url(root_url, self.page),
self.page
);
// injection again
let content = self
.images
.iter()
.map(|x| format!("<img src=\"{}\" /><br />", x))
.fold(String::new(), |mut a, b| {
a.reserve(b.len());
a.push_str(&b);
a
});
ItemBuilder::default()
.title(Some(self.title))
.pub_date(self.date.format(&Iso8601::<ISO8601_DATE>).ok())
.link(Some(self.url.clone()))
.description(Some(desc))
.content(Some(content))
.guid(Some(GuidBuilder::default().value(self.url).build()))
.build()
}