Created
February 21, 2024 06:05
-
-
Save skeptrunedev/d834a9f578b9546d24bced85ccec990c to your computer and use it in GitHub Desktop.
Rust html5ever Scraper Crate Code To Remove table elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mut dom = Html::parse_fragment(&document_without_newlines); | |
// remove tables from the HTML | |
let selector = Selector::parse("table").unwrap(); | |
let node_ids: Vec<_> = dom.select(&selector).map(|x| x.id()).collect(); | |
for id in node_ids { | |
dom.remove_from_parent(&id); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment