pub struct HttpCacheMiddlewareBuilder { /* private fields */ }Expand description
Builder for HttpCacheMiddleware.
Implementations§
Source§impl HttpCacheMiddlewareBuilder
impl HttpCacheMiddlewareBuilder
Sourcepub fn cache_dir(self, path: PathBuf) -> Self
pub fn cache_dir(self, path: PathBuf) -> Self
Sets the directory where cache files will be stored.
Sourcepub fn build(self) -> Result<HttpCacheMiddleware, SpiderError>
pub fn build(self) -> Result<HttpCacheMiddleware, SpiderError>
Builds the HttpCacheMiddleware.
This can fail if the cache directory cannot be created or determined.
Examples found in repository?
examples/quotes_scraper.rs (line 82)
73async fn main() -> Result<(), SpiderError> {
74 tracing_subscriber::fmt()
75 .with_env_filter("info,spider_lib=debug")
76 .without_time()
77 .init();
78
79 let crawler = CrawlerBuilder::<_, ReqwestClientDownloader>::new(QuotesSpider)
80 .add_pipeline(DeduplicationPipeline::new(&["text"]))
81 .add_pipeline(CsvExporterPipeline::<QuoteItem>::new("output/quotes.csv")?)
82 .add_middleware(HttpCacheMiddleware::builder().build()?)
83 .add_middleware(UserAgentMiddleware::builder().build()?)
84 .add_middleware(RobotsTxtMiddleware::new())
85 .add_middleware(
86 RefererMiddleware::new()
87 .same_origin_only(true)
88 .max_chain_length(100)
89 .include_fragment(false),
90 )
91 .with_checkpoint_path("output/quotes.bin")
92 .with_checkpoint_interval(Duration::from_secs(15))
93 .max_concurrent_downloads(5)
94 .max_parser_workers(2)
95 .max_concurrent_pipelines(2)
96 .build()
97 .await?;
98
99 crawler.start_crawl().await?;
100
101 Ok(())
102}Trait Implementations§
Source§impl Default for HttpCacheMiddlewareBuilder
impl Default for HttpCacheMiddlewareBuilder
Source§fn default() -> HttpCacheMiddlewareBuilder
fn default() -> HttpCacheMiddlewareBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for HttpCacheMiddlewareBuilder
impl RefUnwindSafe for HttpCacheMiddlewareBuilder
impl Send for HttpCacheMiddlewareBuilder
impl Sync for HttpCacheMiddlewareBuilder
impl Unpin for HttpCacheMiddlewareBuilder
impl UnwindSafe for HttpCacheMiddlewareBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more