web-scraping - 有没有办法将 Select.rs 的 find 迭代器转换为 Rayon ParallelIterator?
问题描述
我想将 Select.rs 的Find
-iterator 转换为 Rayon ParallelIterator
。我无法通过简单地使用 API 来做到这一点。我怀疑我必须实现或扩展一个特征,但我不知道该怎么做。
我试过收集 Iterator 和 using into_iter
,但无济于事。
use reqwest;
use rayon::prelude::*;
use select::document::Document;
use select::predicate::{Class};
fn main() {
println!("Hello, world!");
let url = "https://pitchfork.com/reviews/albums/";
let response = reqwest::get(url).unwrap();
if response.status().is_success() {
let document = Document::from_read(response).unwrap();
let albums = document.find(Class("review"));
let albums : Vec<String> = albums.par_iter()
.map(|album| album.text()).collect();
}
}
这会导致错误
error[E0599]: no method named `par_iter` found for type `select::document::Find<'_, select::predicate::Class<&str>>` in the current scope
--> src/main.rs:16:40
|
16 | let albums : Vec<String> = albums.par_iter()
| ^^^^^^^^
|
= note: the method `par_iter` exists but the following trait bounds were not satisfied:
`select::document::Find<'_, select::predicate::Class<&str>> : rayon::iter::IntoParallelRefIterator`
我看到该方法par_iter
不存在,但该方法似乎也不存在iter
。
我认为有一种方法可以实现这一点,而无需创建对 select.rs 的拉取请求 - 无论哪种方式,我们都将不胜感激。
解决方案
推荐阅读
- swift - SwiftUI 中的地图和滚动视图
- java - 将变量类型更改为引用类型后,单元测试中的 Java Null 指针异常失败
- javascript - 不渲染新屏幕 usecontext usestate react object boolean simple
- firebase - googlemobileads 包无法导入 Admob 原生广告 Flutter
- python - 与 dict 相比,具有多索引的 loc 的时间复杂度
- pattern-matching - 用于查找不同模式的 Pine Script 例程
- javascript - ExpectSaga 因多个 put 效果而失败
- javascript - div 落后于另一个 div
- go - defer和命名返回值的顺序是什么
- c# - 我很难找到一种方法来跟踪我的角色是否静止以及他们在看什么方向