diff --git a/scraper-rs/src/main.rs b/scraper-rs/src/main.rs index 8461da9..20860a6 100644 --- a/scraper-rs/src/main.rs +++ b/scraper-rs/src/main.rs @@ -208,8 +208,7 @@ async fn parse_file_cli(file_path: String) -> anyhow::Result<()> { dom.query_selector("link[rel=\"canonical\"]") .unwrap() .filter_map(|h| h.get(dom.parser())) - .filter_map(|n| n.as_tag()) - .next() + .find_map(|n| n.as_tag()) .and_then(|t| t.attributes().get("href").flatten()) .expect("No meta canonical") .as_utf8_str() diff --git a/scraper-rs/src/sites/coto.rs b/scraper-rs/src/sites/coto.rs index f667f51..302c62a 100644 --- a/scraper-rs/src/sites/coto.rs +++ b/scraper-rs/src/sites/coto.rs @@ -24,8 +24,7 @@ pub fn parse(url: String, dom: &tl::VDom) -> Result .query_selector(".atg_store_newPrice") .unwrap() .filter_map(|h| h.get(dom.parser())) - .filter_map(|n| n.as_tag()) - .next() + .find_map(|n| n.as_tag()) .map(|t| t.inner_text(dom.parser())) .filter(|s| !s.is_empty()) .map(|s| { @@ -41,8 +40,7 @@ pub fn parse(url: String, dom: &tl::VDom) -> Result dom.query_selector(".product_not_available") .unwrap() .filter_map(|h| h.get(dom.parser())) - .filter_map(|n| n.as_tag()) - .next() + .find_map(|n| n.as_tag()) .is_some(), ); @@ -50,8 +48,7 @@ pub fn parse(url: String, dom: &tl::VDom) -> Result .query_selector("h1.product_page") .unwrap() .filter_map(|h| h.get(dom.parser())) - .filter_map(|n| n.as_tag()) - .next() + .find_map(|n| n.as_tag()) .map(|t| t.inner_text(dom.parser())) .map(|s| s.trim().to_string()); @@ -59,8 +56,7 @@ pub fn parse(url: String, dom: &tl::VDom) -> Result .query_selector(".zoomImage1") .unwrap() .filter_map(|h| h.get(dom.parser())) - .filter_map(|n| n.as_tag()) - .next() + .find_map(|n| n.as_tag()) .and_then(|t| t.attributes().get("src").flatten()) .map(|s| s.as_utf8_str().to_string()); diff --git a/scraper-rs/src/sites/vtex.rs b/scraper-rs/src/sites/vtex.rs index d73bc19..378fc81 100644 --- a/scraper-rs/src/sites/vtex.rs +++ b/scraper-rs/src/sites/vtex.rs @@ -125,7 +125,7 @@ pub async fn get_urls_from_sitemap<'a>(sitemaps: &[&str]) -> anyhow::Result