A crate for manipulating HTML with CSS selectors.
DOM_QUERY is based on HTML crate html5ever and the CSS selector crate selectors. You can use the jQuery-like syntax to query and manipulate an HTML document quickly. Not only can query, but also can modify.
It is a fork of nipper, with some updates. Also this fork supports :has
, :has-text
, :contains
pseudo-classes, and some others.
use dom_query::Document;
fn main() {
let html = include_str!("../test-pages/hacker_news.html");
let document = Document::from(html);
document.select("tr.athing:has(a[href][id])").iter().for_each(|athing| {
let title = athing.select(".title a");
let href = athing.select(".storylink");
println!("{}", title.text());
println!("{}", href.attr("href").unwrap());
});
}
hashbrown
-- optional, standard hashmaps and hashsets will be replacedhashbrown
hashmaps and hashsets;
Licensed under MIT (LICENSE or http://opensource.org/licenses/MIT)
Any contribution intentionally submitted for inclusion in the work by you, shall be licensed with MIT license, without any additional terms or conditions.