Expand description
§millipede
An idiomatic Rust web-crawling library inspired by Crawlee.
§Quick start
[dependencies]
millipede = "0.1.0"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
serde_json = "1"use std::sync::Arc;
use millipede::{CrawlPolicy, Crawler, DatasetExt, HtmlContext, HtmlCrawler, HtmlKind};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let crawler: HtmlCrawler = Crawler::builder(HtmlKind::new()?)
.storage_client(Arc::new(millipede::MemoryStorageClient::new()))
.crawl_policy(CrawlPolicy::new().max_requests_per_crawl(100))
.request_handler(|ctx: HtmlContext| async move {
ctx.storage
.dataset()
.push(&serde_json::json!({
"url": ctx.request.url.as_str(),
"status": ctx.response.status.as_u16(),
}))
.await?;
let _ = ctx.enqueue.same_hostname().await?;
Ok(())
})
.build()
.await?;
let stats = crawler.run("https://example.com/").await?;
println!("finished: {}", stats.requests_finished);
Ok(())
}§Feature flags
http, html, and storage-memory are enabled by default. The core API is always available.
| Feature | Enables | Default |
|---|---|---|
http | Reqwest-based HTTP fetching and HttpCrawler | Yes |
html | HTML parsing and HtmlCrawler | Yes |
storage-memory | In-memory datasets, key-value stores, and request queues | Yes |
storage-fs | File-system-backed storage | No |
browser | Browser crawler abstractions and smart crawling | No |
browser-chromiumoxide | The chromiumoxide CDP provider; also enables browser | No |
fingerprint | Browser-like header generation and fingerprint hooks | No |
§Crawler kinds
HttpCrawler fetches URLs over HTTP and exposes response data, sessions, proxies, and URL enqueueing to handlers.
HtmlCrawler adds synchronized HTML parsing and DOM-based link extraction to HTTP crawling.
BrowserCrawler drives pages through a browser provider for JavaScript-rendered sites.
SmartCrawler starts on the faster HTTP path and promotes requests to a browser when its promotion detector identifies a JavaScript shell or another browser-only response.
§Links
- Autoscaler guide
- Fingerprinting guide
- Crawlee storage migration
- Extras policy
- Examples
- Roadmap
- Interface design
§License
Licensed under either the MIT License or the Apache License, Version 2.0, at your option. Contributions intentionally submitted for inclusion are licensed under the same terms.
Re-exports§
pub use millipede_core as core;pub use millipede_browser as browser;pub use millipede_browser_chromiumoxide as browser_chromiumoxide;pub use millipede_fingerprint as fingerprint;pub use millipede_html as html;pub use millipede_http as http;pub use millipede_storage_fs as storage_fs;pub use millipede_storage_memory as storage_memory;
Modules§
- prelude
- Commonly used items across all enabled Millipede crates.
Structs§
- AddOptions
- Options controlling insertion of requests.
- AddRequests
Batched Result - Completion result for a batched request addition.
- Aimd
Controller - An atomic additive-increase, multiplicative-decrease concurrency controller.
- Anti
BotSignals - Curated public API for ergonomic
millipede::Typeimports. Response signals inspected for evidence of an anti-bot challenge. - Attempt
Observation - Metadata observed after a kind successfully constructs its handler context.
- Attempt
Outcome - Borrowed metadata describing a failed request attempt.
- Attempt
Overrides - Overrides carried to the next attempt of the same request.
- Auto
Saved - A typed value that can be explicitly persisted to a key-value store.
- Autoscaled
Pool - Concurrency decision and politeness facade consulted by a crawler dispatch loop.
- Autoscaled
Pool Options - Configuration for concurrency scaling and request politeness limits.
- Autoscaler
Snapshot - A point-in-time view of a crawler’s concurrency scaler.
- Basic
Context - The handler context for
BasicKind. - Basic
Kind - The no-fetch crawler kind whose execution hands requests directly to handlers.
- Batch
AddHandle - Handle for observing completion of a batched request addition.
- Browser
Context - Per-request context produced by
BrowserKind. - Browser
Fingerprint Generator - A v0.1
post_page_createconsistency stub that produces a consistent user agent andAccept-*/Sec-Ch-Ua-*header set only. - Browser
Hooks - Provider-erased browser lifecycle hooks.
- Browser
Kind - Browser fetching behavior used by
BrowserCrawler. - Browser
Kind Builder - Configures a
BrowserKind. - Browser
Pool - A lazily launched pool of provider browsers and their pages.
- Browser
Pool Options - Configuration for a
BrowserPool. - Browser
Post Hook Ctx - Context supplied to browser post-navigation hooks.
- Browser
PreHook Ctx - Context supplied to browser pre-navigation hooks.
- Browser
Response - Navigation response metadata when the provider can expose it.
- Chromium
Browser - A launched Chromium process and its CDP event driver.
- Chromium
Launch Options - Options used to launch one Chromium process.
- Chromium
Page - A cloneable adapter over a chromiumoxide page.
- Chromiumoxide
Provider - Chromium CDP provider backed by chromiumoxide.
- Client
Load Signal - A manually-fed signal representing downstream client throttling.
- Client
Load Signal Handle - Cloneable manual observation handle for a
ClientLoadSignal. - Coalescing
Client - An HTTP client decorator that joins safe, identical requests already in flight.
- Configuration
- Fully resolved crawler configuration.
- Configuration
Builder - Builds a resolved
Configuration. - Cookie
- A transport-neutral HTTP cookie shared by HTTP and browser crawler contexts.
- Cookie
Jar - A synchronized cookie store shared by crawler sessions.
- CpuLoad
Signal - Periodically samples aggregate system CPU usage.
- CpuLoad
Signal Options - Options for periodic system CPU load sampling.
- Crawl
Policy - Long-lived limits and URL admission policy applied during a crawl.
- Crawler
- A configured crawler using lifecycle behavior supplied by
K. - Crawler
Builder - Builds a
Crawleraround a crawler kind. - Crawler
Env - Shared process-level state supplied to crawler lifecycle hooks.
- Crawler
Handle - A cheaply cloned weak back-reference to a running crawler.
- Dataset
Info - Dataset identity and timestamps.
- Default
Anti BotDetector - Curated public API for ergonomic
millipede::Typeimports. A conservative detector using bounded, vendor-specific static markers. - Default
Promotion Detector - Conservative built-in promotion heuristics.
- Domain
Round Robin - A pure frontier that rotates fairly between URL hosts.
- Enqueue
Linker - Enqueues child URLs through a running crawler.
- Enqueue
Links Options - Fluent options for one URLs-only enqueue operation.
- Enqueue
Result - Result of enqueueing a URL collection.
- Error
Snapshot - A failure-time artifact reloaded from storage.
- Error
Snapshotter - Captures and reloads failure-time artifacts in a crawler key-value store.
- Event
Bus - A broadcast channel for crawler control-plane events.
- Extracted
Link - A raw extracted link and the optional document base used to resolve it.
- Failed
Request Context - Owned payload handed to the failure handler when a request permanently fails.
- Final
Statistics - Crawl statistics returned when a run finishes.
- FsDataset
- A file-system-backed, append-only JSON dataset.
- FsKey
Value Store - A file-system-backed byte-oriented key-value store.
- FsRequest
Queue - A durable FIFO request queue backed by atomic file replacements.
- FsStorage
Client - A file-system storage client using Crawlee-compatible directory layouts.
- Glob
Pattern - An include glob or regular expression with optional per-pattern overrides.
- Goto
Options - Options controlling a page navigation.
- Handled
Request - The terminal result of processing one request.
- Header
Generator - Deterministically selects browser-like header profiles from a curated dataset.
- Header
Map - A specialized multimap for header names and values.
- Header
Profile - A browser user agent and its ordered companion HTTP headers.
- Html
Context - Per-request context produced by
HtmlKind. - Html
Kind - HTML fetching behavior that delegates transport concerns to
HttpKind. - Html
Kind Builder - Configures
HtmlKindby delegating HTTP settings toHttpKindBuilder. - Html
Link Extractor - Extracts raw link targets from an already-parsed HTML document.
- Http
Attempt Snapshot - A borrowed snapshot of one successful HTTP/HTML attempt.
- Http
Context - Per-request context produced by
HttpKind. - Http
Kind - HTTP fetching behavior used by
HttpCrawler. - Http
Kind Builder - Configures
HttpKind. - Http
Post Hook Ctx - State exposed after an HTTP response is received.
- Http
PreHook Ctx - State exposed immediately before an HTTP request is sent.
- Http
Request - A backend-independent HTTP request.
- Http
Response - A fully buffered HTTP response.
- Http
Status Error - A typed HTTP status carried inside a
crate::errors::CrawlError. - KeyInfo
- Metadata for one stored key.
- KeyList
- A page of keys and continuation metadata.
- KvEntry
- A stored byte value and its metadata.
- Launch
Context - Process-level context applied when launching a browser.
- Lease
- Temporary, linear ownership of a queued request.
- LeaseId
- Identifier for one active request lease.
- List
Keys Options - Options controlling key pagination.
- List
Options - Options controlling dataset listing order and pagination.
- Load
Snapshot - A point-in-time overload observation from a load signal.
- Memory
Dataset - An in-process, append-only JSON dataset.
- Memory
KeyValue Store - An in-process byte-oriented key-value store.
- Memory
Load Signal - Periodically samples used system memory against a configurable budget.
- Memory
Load Signal Options - Options for periodic system memory load sampling.
- Memory
Request Queue - A thread-safe, lease-based request queue stored entirely in memory.
- Memory
Storage Client - An in-process storage client that shares named stores across open calls.
- Method
- The Request Method (VERB)
- Page
- A page of dataset items and pagination metadata.
- Page
Handle - Provider-erased RAII handle for a page checked out from a
BrowserPool. - PageId
- Stable process-local identifier for a pooled browser page.
- Page
Options - Per-page creation context consumed by browser hooks.
- Processed
Request - Result metadata for adding one request.
- Proxy
Buckets - Named proxy configurations with deterministic fallbacks.
- Proxy
Configuration - Static, custom, or per-domain tiered proxy selection.
- Proxy
Info - Parsed connection details for a selected proxy.
- Proxy
Resolve Context - Borrowed inputs available to proxy resolution.
- Proxy
Route Context - Borrowed inputs available to a
ProxyStrategy. - Rate
Limit Reporting Client - A storage client wrapper that reports healthy and rate-limited operations to autoscaling.
- Reclaim
Options - Options controlling return of a leased request to the queue.
- Request
- A crawl request and its processing state.
- Request
Builder - Builds a
Requestwhile deferring parsing and serialization errors. - Request
Env - Per-attempt inputs supplied to
CrawlerKind::execute. - Request
Id - A deterministic request identifier.
- Request
Prep - Engine-owned scratch space passed to
CrawlerKind::before_request. - Request
Queue With Sitemap - A request queue that lazily feeds sitemap entries into another queue.
- Reqwest
Client - A reqwest-backed
HttpClientwith manual redirect and cookie handling. - Reqwest
Client Options - Configuration for
ReqwestClient. - Retry
Directive - Owned instructions returned by a
RetryStrategy. - Router
- Routes request contexts by label and HTTP method.
- Screenshot
Options - Options controlling screenshot capture.
- Session
- Cookie, score, and user-data state associated with a crawling identity.
- Session
Config - Limits and scoring behavior for one session.
- Session
Id - Stable identifier for a crawler session.
- Session
Pool - A bounded collection of reusable crawler sessions.
- Session
Pool Options - Session pool capacity, creation, and persistence settings.
- Session
Token - Stable token used to keep fingerprint generation consistent within a session.
- Sitemap
Entry - One URL entry parsed from a sitemap document.
- Sitemap
Request List - A lazy, streaming source of requests parsed from XML sitemaps.
- Sitemap
Request List Builder - Configures a streaming
SitemapRequestList. - Skipped
Url - A skipped URL candidate.
- Smart
Kind - HTTP-first execution with conservative browser promotion.
- Smart
Kind Builder - Configures
SmartKind. - Snapshotter
- Coordinates lifecycle and access to configured load signals.
- Snapshotter
Options - Configuration for a collection of load signals and their sampling window.
- Statistics
Handle - A cheaply cloned handle for recording and reading crawl statistics.
- Statistics
Snapshot - A point-in-time view of crawl statistics.
- Storage
Handle - Open storage resources shared by crawler contexts.
- Streaming
Response - An HTTP response whose body arrives as a byte stream.
- Synchronized
Html - A parsed HTML document with the synchronization required for shared handler access.
- System
Status - Evaluates load-signal histories into scaling decisions.
- System
Status Options - Options controlling load-history evaluation.
- Tokio
Runtime Load Signal - Detects Tokio executor load by measuring stable-API timer scheduling lag.
- Tokio
Runtime Load Signal Options - Options for detecting Tokio executor scheduling lag.
- UrlMatch
- A URL pattern with request fields to apply when it matches.
- User
Data - User-defined JSON metadata attached to a request.
Enums§
- Anti
BotTech - A recognized anti-bot or web application firewall technology.
- Autoscale
Mode - Strategy used to adjust desired concurrency.
- Browser
Error - An error produced while launching or operating a browser.
- Config
Error - Errors produced while resolving crawler configuration.
- Cookie
JarError - An error serializing or deserializing a cookie jar.
- Crawl
Error - An error produced while processing a crawl request.
- Crawler
Build Error - An error produced while building a crawler.
- Crawler
Event - A control-plane event emitted during a crawler run.
- Enqueue
Strategy - Controls how closely a discovered URL must relate to its parent URL.
- Html
Error - Errors specific to HTML response processing.
- Http
Client Error - An error produced while preparing or executing an HTTP request.
- Link
Pattern Error - An error produced while compiling link patterns.
- LogLevel
- Logging verbosity for crawler diagnostics.
- Memory
Queue Policy - Ordering policy used by an in-memory request queue.
- Method
Filter - Restricts a route to selected HTTP methods.
- Promotion
Reason - Why an HTTP attempt should be repeated through a browser.
- Proxy
Kind - Logical proxy configuration bucket.
- Request
Body - A supported request-body representation.
- Request
Build Error - Errors encountered while building a request.
- Request
Final State - A request’s terminal processing state.
- Request
Outcome - The outcome supplied to per-attempt cleanup.
- Request
Source - A source from which requests can be added.
- Request
State - The processing lifecycle state of a request.
- Rotation
Strategy - Selection policy for a static proxy list.
- Same
Site - A cookie’s cross-site request policy.
- Scale
Decision - The concurrency adjustment recommended by current system load.
- Session
Retry Action - Session disposition for a strategy-authorized retry.
- Skip
Reason - Why an enqueue candidate was skipped.
- Smart
Context - A context produced by either the HTTP/HTML or browser execution path.
- Storage
Error - An error produced by a storage backend.
- Transform
Result - The outcome of transforming a candidate request before enqueueing.
- UrlPattern
- A URL include or exclude pattern.
- Wait
Until - Browser lifecycle event awaited after navigation.
Constants§
- SESSION_
POOL_ PERSIST_ KEY - Default key used to persist the session pool.
- SITEMAP_
STATE_ KEY - Conventional key used to persist sitemap request-list progress.
- STATISTICS_
PERSIST_ KEY - KVS key used for statistics persistence (matches Crawlee).
Traits§
- Anti
BotDetector - Curated public API for ergonomic
millipede::Typeimports. Detects anti-bot or web application firewall responses from response signals. - Browser
Page - Object-safe browser page surface implemented by concrete providers.
- Browser
Promotion Detector - Decides whether a successful HTTP/HTML attempt needs browser execution.
- Browser
Provider - Concrete browser backend used by a browser pool.
- Crawler
Kind - Defines the complete lifecycle for one crawler flavor.
- Dataset
- Object-safe storage for append-only JSON records.
- Dataset
Ext - Typed convenience operations available on every
Dataset. - Failed
Request Handler - Handles a request after it has permanently failed.
- HasRequest
- Provides request metadata used to select a route.
- Http
Client - An object-safe asynchronous HTTP client backend.
- Into
Start Request - A single value convertible into one start
Request. - Into
Start Requests - A collection of start requests accepted by
super::Crawler::run. - IntoUrl
- Conversion into a parsed URL for request builders.
- KeyValue
Store - Object-safe byte-oriented key-value storage.
- KeyValue
Store Ext - Typed JSON convenience operations available on every
KeyValueStore. - Link
Extractor - Extracts links from a static document or live browser page.
- Load
Signal - A source of recent system or client load observations.
- Middleware
- Transforms a request context before its matched handler runs.
- Proxy
Resolver - Asynchronous custom proxy URL resolver.
- Proxy
Strategy - Synchronous policy selecting a proxy bucket for a request.
- Request
Handler - Processes an owned request context.
- Request
Queue - Object-safe queue with temporary lease ownership.
- Retry
Strategy - Controls retries and next-attempt overrides for non-critical failures.
- Skipped
Handler - Receives notifications for URL candidates skipped during enqueueing.
- Storage
Client - Opens named or default storage objects supplied by a backend.
Functions§
- find_
browser - Finds a supported Chromium or Google Chrome executable.
Type Aliases§
- Basic
Crawler - The no-HTTP crawler: drives the queue and hands requests straight to the handler.
- Browser
Crawler - A crawler using
BrowserKindto render requests in browser pages. - Browser
Post Navigation Hook - Asynchronous browser hook run after navigation and status classification.
- Browser
PreNavigation Hook - Asynchronous browser hook run after page creation and before navigation.
- Event
Stream - A receiver for crawler events.
- Html
Crawler - A crawler using
HtmlKindto fetch and parse HTML documents. - Http
Crawler - A crawler using
HttpKindto fetch raw HTTP responses. - Http
Post Navigation Hook - Asynchronous hook run after an HTTP response is received and anti-bot detection completes.
- Http
PreNavigation Hook - Asynchronous hook run immediately before an HTTP request is sent.
- Page
Closed Hook - Synchronous notification run after a page has closed.
- Page
Hook - Asynchronous hook operating on a provider-erased page and its creation context.
- Page
Prep Hook - Synchronous hook that prepares per-page creation context.
- PreLaunch
Hook - Synchronous hook run before a browser launches.
- Queue
OpInfo - Alternate interface spelling for
ProcessedRequest; both names describe the same payload. - Result
Stream - A receiver for terminal request snapshots (the data-plane feed).
- Smart
Crawler - A crawler using
SmartKindfor HTTP-first browser promotion. - Storage
Result - Result type returned by every storage operation.