770 stable releases

new 2.37.81 May 26, 2025
2.36.120 Apr 28, 2025
2.36.7 Mar 31, 2025
2.23.3 Dec 31, 2024
0.1.3 Jul 24, 2024

#2216 in Command line utilities

Download history 2587/week @ 2025-02-03 1919/week @ 2025-02-10 3622/week @ 2025-02-17 1171/week @ 2025-02-24 2432/week @ 2025-03-03 2854/week @ 2025-03-10 1048/week @ 2025-03-17 3018/week @ 2025-03-24 2903/week @ 2025-03-31 1722/week @ 2025-04-07 4104/week @ 2025-04-14 4146/week @ 2025-04-21 928/week @ 2025-04-28 1907/week @ 2025-05-05 4102/week @ 2025-05-12 3084/week @ 2025-05-19

10,549 downloads per month

MIT license

22KB
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–26MB
~448K SLoC