8 releases

new 0.3.4 Feb 17, 2024
0.3.3 Feb 10, 2024
0.3.2 Jan 19, 2024
0.3.0 Dec 31, 2023
0.1.11 Dec 22, 2023

#2 in #html5ever

Download history 51/week @ 2023-12-21 89/week @ 2023-12-28 25/week @ 2024-01-04 47/week @ 2024-01-11 74/week @ 2024-01-18 42/week @ 2024-01-25 16/week @ 2024-02-01 48/week @ 2024-02-08

187 downloads per month
Used in dom_finder

MIT license

180KB
2K SLoC

DOM_QUERY

A crate for manipulating HTML with CSS selectors.

Crates.io version Download docs.rs docs Build Status CircleCI

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.

Example

Extract the hacker news.

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());
    });
}

Readability.

examples/readability.rs

Features

  • hashbrown -- optional, standard hashmaps and hashsets will be replaced hashbrown hashmaps and hashsets;

Changelog

Changelog

License

Licensed under MIT (LICENSE or http://opensource.org/licenses/MIT)

Contribution

Any contribution intentionally submitted for inclusion in the work by you, shall be licensed with MIT license, without any additional terms or conditions.

Dependencies

~3–10MB
~85K SLoC