From 8e9192ce988373229b87385fc4957d4dafa61dc6 Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Sat, 18 Nov 2023 09:59:07 +0100 Subject: [PATCH] allow empty text --- src/scrapers.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/scrapers.rs b/src/scrapers.rs index ba9fa6f..ed1d8db 100644 --- a/src/scrapers.rs +++ b/src/scrapers.rs @@ -75,17 +75,17 @@ fn parse_footprint( .attr("content")?; let format = format_description::parse("[year]-[month]-[day]").ok()?; let date = Date::parse(date, &format).ok()?; - let text = footprint_el - .select(text_selector) - .next()? - .text() - .next()? - .to_string(); - let text = if let Some(text_rest) = footprint_el.select(text_rest_selector).next() { - format!("{}{}", text, text_rest.text().next()?) + let text = if let Some(text) = footprint_el.select(text_selector).next() { + let text = text.text().next()?.to_string(); + + if let Some(text_rest) = footprint_el.select(text_rest_selector).next() { + format!("{}{}", text, text_rest.text().next()?) + } else { + text + } } else { - text + "".to_string() } .trim() .to_string();