Crates.io | spider_utils |
lib.rs | spider_utils |
version | 2.21.20 |
source | src |
created_at | 2024-07-24 13:17:57.822249 |
updated_at | 2024-12-12 19:24:11.458765 |
description | Utilities to use for Spider Web Crawler. |
homepage | |
repository | https://github.com/spider-rs/spider |
max_upload_size | |
id | 1313984 |
size | 13,463 |
Utilities to use to help with getting the most out of spider.
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"]}
}
You can use the feature flag indexset
to order the CSS scraping extraction order.