forked from spider-rs/spider
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcron.rs
More file actions
25 lines (19 loc) · 712 Bytes
/
Copy pathcron.rs
File metadata and controls
25 lines (19 loc) · 712 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
//! `cargo run --example cron`
extern crate spider;
use spider::tokio;
use spider::website::{run_cron, Website};
#[tokio::main]
async fn main() {
let mut website: Website = Website::new("https://rsseau.fr/en");
website.configuration.cron_str = "1/5 * * * * *".into();
let mut rx2 = website.subscribe(16).unwrap();
let join_handle = tokio::spawn(async move {
while let Ok(res) = rx2.recv().await {
println!("{:?}", res.get_url());
}
});
let mut runner = run_cron(website).await;
println!("Starting the Runner for 20 seconds");
tokio::time::sleep(tokio::time::Duration::from_secs(20)).await;
let _ = tokio::join!(runner.stop(), join_handle);
}