dom_query 0.27.0

HTML querying and manipulation with CSS selectors
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use dom_query::Document;

fn main() {
    let html = include_str!("../test-pages/hacker_news.html");
    let document = Document::from(html);

    for news in document.select("tr.athing:has(a[href][id])").iter() {
        let link = news.select(".title  a.storylink");
        let source = news.select(".sitebit a");
        println!("{:<6} => {}", "title", link.text());
        println!("{:<6} => {}", "link", link.attr("href").unwrap_or_default());
        println!("{:<6} => {}\n", "source", source.text());
    }
}