547 stable releases

new 2.33.19 Mar 16, 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

#2127 in Web programming

Download history 8334/week @ 2024-11-25 3507/week @ 2024-12-02 4195/week @ 2024-12-09 683/week @ 2024-12-16 832/week @ 2024-12-23 2393/week @ 2024-12-30 2141/week @ 2025-01-06 502/week @ 2025-01-13 2225/week @ 2025-01-20 2841/week @ 2025-01-27 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 2200/week @ 2025-03-10

9,756 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
~447K SLoC