spider_utils

Crates.iospider_utils
lib.rsspider_utils
version2.13.7
sourcesrc
created_at2024-07-24 13:17:57.822249
updated_at2024-11-09 18:27:36.31438
descriptionUtilities to use for Spider Web Crawler.
homepage
repositoryhttps://github.com/spider-rs/spider
max_upload_size
id1313984
size13,596
Jeff Mendez (j-mendez)

documentation

https://docs.rs/spider

README

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.

Commit count: 856

cargo fmt