mirror of
https://gitlab.com/news-flash/article_scraper.git
synced 2025-07-10 01:15:31 +02:00
tmp: dont strip scripts
This commit is contained in:
parent
23514aff9e
commit
98348b7e59
1 changed files with 20 additions and 22 deletions
42
src/lib.rs
42
src/lib.rs
|
@ -121,10 +121,10 @@ impl ArticleScraper {
|
||||||
return Err(error);
|
return Err(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(error) = ArticleScraper::eliminate_noscrip_tag(&context) {
|
// if let Err(error) = ArticleScraper::eliminate_noscript_tag(&context) {
|
||||||
error!("Eliminating <noscript> tag failed - '{}'", error);
|
// error!("Eliminating <noscript> tag failed - {}", error);
|
||||||
return Err(error);
|
// return Err(error)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if download_images {
|
if download_images {
|
||||||
if let Err(error) = self
|
if let Err(error) = self
|
||||||
|
@ -646,7 +646,7 @@ impl ArticleScraper {
|
||||||
);
|
);
|
||||||
|
|
||||||
// strip all scripts
|
// strip all scripts
|
||||||
let _ = ArticleScraper::strip_node(&context, &String::from("//script"));
|
//let _ = ArticleScraper::strip_node(&context, &String::from("//script"));
|
||||||
|
|
||||||
// strip all comments
|
// strip all comments
|
||||||
let _ = ArticleScraper::strip_node(&context, &String::from("//comment()"));
|
let _ = ArticleScraper::strip_node(&context, &String::from("//comment()"));
|
||||||
|
@ -782,23 +782,21 @@ impl ArticleScraper {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eliminate_noscrip_tag(context: &Context) -> Result<(), ScraperError> {
|
// fn eliminate_noscript_tag(context: &Context) -> Result<(), ScraperError> {
|
||||||
let xpath = "//noscript";
|
// let xpath = "//noscript";
|
||||||
let node_vec = Self::evaluate_xpath(context, xpath, false)?;
|
// let node_vec = Self::evaluate_xpath(context, xpath, false)?;
|
||||||
|
// for mut node in node_vec {
|
||||||
for mut node in node_vec {
|
// if let Some(mut parent) = node.get_parent() {
|
||||||
if let Some(mut parent) = node.get_parent() {
|
// node.unlink();
|
||||||
node.unlink();
|
// let children = node.get_child_nodes();
|
||||||
let children = node.get_child_nodes();
|
// for mut child in children {
|
||||||
for mut child in children {
|
// child.unlink();
|
||||||
child.unlink();
|
// let _ = parent.add_child(&mut child);
|
||||||
let _ = parent.add_child(&mut child);
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// Ok(())
|
||||||
|
// }
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue