9 releases

0.3.5 Apr 4, 2024
0.3.4 Feb 17, 2024
0.3.2 Jan 19, 2024
0.3.0 Dec 31, 2023
0.1.11 Dec 22, 2023

#2018 in Web programming

Download history 8/week @ 2023-12-29 4/week @ 2024-01-05 7/week @ 2024-01-12 26/week @ 2024-01-19 5/week @ 2024-01-26 157/week @ 2024-02-16 25/week @ 2024-02-23 4/week @ 2024-03-01 12/week @ 2024-03-08 5/week @ 2024-03-15 111/week @ 2024-03-29 51/week @ 2024-04-05 3/week @ 2024-04-12

165 downloads per month
Used in dom_finder

MIT license

185KB
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

~2.6–8.5MB
~72K SLoC