spider-util
spider-util is the shared types-and-helpers crate for the workspace. It is used internally by the other spider-* crates, and it is also the crate extension authors usually reach for first when they need the framework's request, response, item, or error types.
This is not the crawler runtime itself. Think of it as the common language the rest of the workspace speaks.
When to use it directly
Use spider-util when you need:
- request and response models shared across the runtime
ScrapedItemandParseOutput- framework-native errors such as
SpiderErrorandPipelineError - selector and utility helpers already used across the workspace
If you are only writing an application spider, these types are often easier to access through spider-lib or spider-core.
Installation
[]
= "0.3.5"
What it contains
request: request model used by spiders, middleware, and downloadersresponse: response model returned by downloaders and consumed by parsersitem:ScrapedItemandParseOutputerror:SpiderErrorandPipelineErrorselector: HTML selector helpersutil,formatters,metrics, and other support modules used across the ecosystem
Example
use ;
use Url;
let request = new;
let mut output = new;
output.add_request;
output.add_item;
You will probably want this crate if
- you are implementing a custom
Downloader - you are implementing a custom
Middleware - you are implementing a custom
Pipeline - you want shared framework types without depending on the application-facing facade
Related crates
License
MIT. See LICENSE.