use async_std::task; use async_trait::async_trait; use medina::{Crawler, Error, Page, PageResult}; pub struct RootPage { pub url: String, } pub struct FakePage { pub url: String, } #[async_trait] impl Page for RootPage { async fn process_request( &self, ) -> Result<(Vec>, Vec>), Error> { let mut vec: Vec> = Vec::with_capacity(50 * 26); for ch in b'a'..(b'z' + 1) { for i in 1..50 + 1 { vec.push(Box::new(FakePage { url: format!("https://{}.com/{}", ch as char, i), })); } } return Ok((vec, Vec::new())); } fn get_url(&self) -> &String { return &self.url; } } #[async_trait] impl Page for FakePage { async fn process_request( &self, ) -> Result<(Vec>, Vec>), Error> { return Ok((Vec::new(), Vec::new())); } fn get_url(&self) -> &String { return &self.url; } } fn main() { task::block_on(async { Crawler::with_capacity(50 * 26, 0.0001) .set_default_request_rate(5.0) .push_item(Box::new(RootPage { url: "https://root.com".to_string(), })) .run(50, 30) .await; }) }