580 stable releases

new 2.36.6 Mar 30, 2025
2.31.4 Feb 28, 2025
2.23.3 Dec 31, 2024
2.13.84 Nov 30, 2024
0.1.3 Jul 24, 2024

#2430 in Command line utilities

Download history 4193/week @ 2024-12-08 847/week @ 2024-12-15 927/week @ 2024-12-22 1832/week @ 2024-12-29 2473/week @ 2025-01-05 671/week @ 2025-01-12 1783/week @ 2025-01-19 3086/week @ 2025-01-26 2710/week @ 2025-02-02 1751/week @ 2025-02-09 3609/week @ 2025-02-16 1321/week @ 2025-02-23 2126/week @ 2025-03-02 2915/week @ 2025-03-09 1691/week @ 2025-03-16 2905/week @ 2025-03-23

9,789 downloads per month

MIT license

23KB
287 lines

spider_utils

Utilities to use to help with getting the most out of spider.

CSS Scraping

use spider::{
    hashbrown::HashMap,
    packages::scraper::Selector,
};
use spider_utils::{QueryCSSMap, QueryCSSSelectSet, build_selectors, css_query_select_map_streamed};

async fn css_query_selector_extract() {
    let map = QueryCSSMap::from([(
        "list",
        QueryCSSSelectSet::from([".list", ".sub-list"]),
    )]);
    let data = css_query_select_map_streamed(
        r#"<html>
            <body>
                <ul class="list"><li>First</li></ul>
                <ul class="sub-list"><li>Second</li></ul>
            </body>
        </html>"#,
        &build_selectors(map),
    )
    .await;

    println!("{:?}", data);
    // {"list": ["First", "Second"]}
}

Features

You can use the feature flag indexset to order the CSS scraping extraction order.

Dependencies

~10–25MB
~449K SLoC