CrawlResult class represents the complete result from a spider run, including scraped items, statistics, and pause state.
Class Definition
Attributes
CrawlStats
required
Detailed statistics about the crawl (requests, items, timing, etc.).
ItemList
required
List of scraped items with export capabilities.
bool
default:"False"
Whether the crawl was paused (True) or completed normally (False).
Properties
completed
not self.paused
Special Methods
Length
Iteration
ItemList
Theitems attribute is an ItemList - a list subclass with export methods.
to_json
str | Path
required
Path to the output file.
bool
default:"False"
Pretty-print with 2-space indentation (slightly slower).
to_jsonl
str | Path
required
Path to the output file.
CrawlStats
Thestats attribute contains detailed crawl metrics.
Attributes
int
default:"0"
Total number of successful requests made.
int
default:"0"
Maximum concurrent requests setting.
int
default:"0"
Maximum concurrent requests per domain setting.
int
default:"0"
Number of failed requests (exceptions during fetch).
int
default:"0"
Number of requests filtered due to
allowed_domains.int
default:"0"
Number of requests detected as blocked.
int
default:"0"
Total bytes downloaded.
int
default:"0"
Number of items successfully scraped.
int
default:"0"
Number of items dropped by
on_scraped_item().float
default:"0.0"
Timestamp when crawl started.
float
default:"0.0"
Timestamp when crawl ended.
float
default:"0.0"
Download delay setting.
Dict
default:"{}"
User-defined custom statistics.
Dict
default:"{}"
Count of responses by status code (e.g.,
{"status_200": 42, "status_404": 3}).Dict
default:"{}"
Bytes downloaded per domain.
Dict
default:"{}"
Requests made per session ID.
List[str | Dict | Tuple]
default:"[]"
List of proxies used during the crawl.
Dict
default:"{}"
Count of log messages by level (debug, info, warning, error, critical).
Properties
elapsed_seconds
end_time - start_time
requests_per_second
requests_count / elapsed_seconds (or 0.0 if elapsed_seconds == 0)
Methods
to_dict
Usage Examples
Basic Usage
Export Results
Iterate Items
Detailed Statistics
Handle Paused Crawls
Custom Statistics
Performance Analysis
Logging Analysis
Complete Example
See Also
- Spider - Running spiders and getting results
- CrawlerEngine - Understanding statistics collection