462 stable releases

new 2.27.57 Feb 13, 2025
2.27.27 Jan 30, 2025
2.23.3 Dec 31, 2024
2.13.84 Nov 30, 2024
0.1.3 Jul 24, 2024

#2139 in Web programming

Download history 2327/week @ 2024-10-24 3739/week @ 2024-10-31 1480/week @ 2024-11-07 439/week @ 2024-11-14 6843/week @ 2024-11-21 4351/week @ 2024-11-28 3433/week @ 2024-12-05 2811/week @ 2024-12-12 988/week @ 2024-12-19 1414/week @ 2024-12-26 2123/week @ 2025-01-02 1387/week @ 2025-01-09 440/week @ 2025-01-16 3809/week @ 2025-01-23 2060/week @ 2025-01-30 2091/week @ 2025-02-06

8,460 downloads per month

MIT license

15KB
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
~469K SLoC