mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-25 19:16:19 +00:00
limpiar código
This commit is contained in:
parent
c1111b112e
commit
d233dbd259
3 changed files with 6 additions and 11 deletions
|
@ -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()
|
||||
|
|
|
@ -24,8 +24,7 @@ pub fn parse(url: String, dom: &tl::VDom) -> Result<PrecioPoint, anyhow::Error>
|
|||
.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<PrecioPoint, anyhow::Error>
|
|||
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<PrecioPoint, anyhow::Error>
|
|||
.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<PrecioPoint, anyhow::Error>
|
|||
.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());
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ pub async fn get_urls_from_sitemap<'a>(sitemaps: &[&str]) -> anyhow::Result<Vec<
|
|||
let client = &client;
|
||||
async move {
|
||||
let text = get_retry_policy()
|
||||
.retry(|| do_request(client, &url))
|
||||
.retry(|| do_request(client, url))
|
||||
.await?
|
||||
.text()
|
||||
.await?;
|
||||
|
|
Loading…
Reference in a new issue