-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathchrome_viewport.rs
More file actions
37 lines (30 loc) · 938 Bytes
/
chrome_viewport.rs
File metadata and controls
37 lines (30 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! `cargo run --example chrome_viewport --features chrome`
extern crate spider;
use spider::configuration::Viewport;
use spider::tokio;
use spider::website::Website;
#[tokio::main]
async fn main() {
let mut website: Website = Website::new("https://choosealicense.com")
.with_viewport(Some(Viewport::new(375, 500)))
.build()
.unwrap();
let mut rx2 = website.subscribe(16);
tokio::spawn(async move {
while let Ok(page) = rx2.recv().await {
println!("{:?}", page.get_url());
}
});
let start = crate::tokio::time::Instant::now();
website.crawl().await;
let duration = start.elapsed();
let links = website.get_all_links_visited().await;
for link in links.iter() {
println!("- {:?}", link.as_ref());
}
println!(
"Time elapsed in website.crawl() is: {:?} for total pages: {:?}",
duration,
links.len()
)
}