647 stable releases

new 2.36.79 Apr 19, 2025
2.36.7 Mar 31, 2025
2.23.3 Dec 31, 2024
2.13.84 Nov 30, 2024
0.1.3 Jul 24, 2024

#2039 in Command line utilities

Download history 1719/week @ 2024-12-28 1917/week @ 2025-01-04 1221/week @ 2025-01-11 1096/week @ 2025-01-18 3669/week @ 2025-01-25 2483/week @ 2025-02-01 1928/week @ 2025-02-08 3034/week @ 2025-02-15 2045/week @ 2025-02-22 1476/week @ 2025-03-01 2976/week @ 2025-03-08 2119/week @ 2025-03-15 2225/week @ 2025-03-22 2625/week @ 2025-03-29 2903/week @ 2025-04-05 3564/week @ 2025-04-12

11,480 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
~450K SLoC