Skip to content

Instantly share code, notes, and snippets.

@skeptrunedev
Created February 21, 2024 06:05
Show Gist options
  • Save skeptrunedev/d834a9f578b9546d24bced85ccec990c to your computer and use it in GitHub Desktop.
Save skeptrunedev/d834a9f578b9546d24bced85ccec990c to your computer and use it in GitHub Desktop.
Rust html5ever Scraper Crate Code To Remove table elements
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