From afe661fe6c4bd9c7495a569f54a644ce5df54497 Mon Sep 17 00:00:00 2001 From: Jan Lukas Gernert Date: Mon, 27 Jan 2020 01:54:37 +0100 Subject: [PATCH] only go for single page link if xpath res isn't empty --- src/lib.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index ce2f523..f55315e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -171,12 +171,14 @@ impl ArticleScraper { xpath_single_page_link ); if let Ok(result) = xpath_ctx.findvalue(&xpath_single_page_link, None) { - // parse again with single page url - debug!("Single page link found '{}'", result); - let single_page_url = url::Url::parse(&result).context(ScraperErrorKind::Url)?; - return self - .parse_single_page(article, &single_page_url, root, config) - .await; + if !result.trim().is_empty() { + // parse again with single page url + debug!("Single page link found '{}'", result); + let single_page_url = url::Url::parse(&result).context(ScraperErrorKind::Url)?; + return self + .parse_single_page(article, &single_page_url, root, config) + .await; + } } }