627 stable releases

new 2.36.59 Apr 15, 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 1423/week @ 2024-12-24 2125/week @ 2024-12-31 1907/week @ 2025-01-07 437/week @ 2025-01-14 2774/week @ 2025-01-21 2367/week @ 2025-01-28 2762/week @ 2025-02-04 1864/week @ 2025-02-11 3641/week @ 2025-02-18 1098/week @ 2025-02-25 2571/week @ 2025-03-04 2758/week @ 2025-03-11 883/week @ 2025-03-18 3192/week @ 2025-03-25 3305/week @ 2025-04-01 2037/week @ 2025-04-08

9,645 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

~11–26MB
~471K SLoC