Skip to main content

scrapy-spider-monitor

A small Scrapy extension that records per-field fill rates in your job stats, so Spider Monitor can flag a spider that "finishes fine" while a field has quietly gone empty after a site layout change.

It reads only field names, whether values are empty, and response body sizes, and keeps numeric counters in memory. Item values are never stored, logged or sent anywhere. The only output is the job's own stats.

Install

pip install scrapy-spider-monitor   # on Scrapy Cloud, add scrapy-spider-monitor to requirements.txt
# settings.py:
EXTENSIONS = {"spidermonitor_scrapy.FillRateExtension": 500}

Requires Python 3.10+ and Scrapy 2.11+.

What it writes

When the spider closes, for each top-level field:

Stat Meaning
fill_rate/<field>/count Items where the field was present and non-empty
fill_rate/<field>/rate count / item_scraped_count, from 0 to 1 (omitted when there are 0 items)
item_scraped_count The denominator. Scrapy normally sets it; the extension sets it if it is missing

For responses that produced at least one item (each counted once, however many items it yielded; items not tied to a response are skipped):

Stat Meaning
item_responses/count Responses that produced items
item_responses/body_length/min Smallest body, in bytes (omitted when the count is 0)
item_responses/body_length/avg Mean body, in bytes (omitted when the count is 0)

Per-status response counts are already in every job's stats as downloader/response_status_count/<code> (Scrapy's built-in DownloaderStats), so this extension does not duplicate them.

None, whitespace-only strings ("", " ", "\n ") and empty containers ([], {}, (), b"") count as empty. Whitespace counts as empty because a broken selector often returns it instead of None. 0 and False count as values. A missing key counts as empty.

Works with dicts, scrapy.Item, dataclass and attrs items (via itemadapter). Fields declared on an Item, dataclass or attrs class are reported even if they were never set, so a field that is empty in every item shows up as count 0. For plain dicts, a field is reported once it has appeared as a key in at least one item.

Optional settings

# Track only these fields. Listed fields are always reported, even if no item has them.
SPIDERMONITOR_FIELDS = ["title", "price", "sku"]

# Turn the extension off without removing it from EXTENSIONS.
SPIDERMONITOR_FILL_RATE_ENABLED = False

Cost

One dictionary update per field per item, one set lookup per item for the response, and no I/O during the crawl. Responses are tracked by weak reference, so they are not kept in memory. Stats are written once, in spider_closed. Only top-level fields are counted; nested fields are not counted in this version.

Development

python -m venv .venv && . .venv/bin/activate
pip install -e '.[test]'
pytest

License

MIT

Metadata

Release files for scrapy-spider-monitor 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scrapy-spider-monitor 0.1.0
File Size Uploaded Provenance Actions
scrapy_spider_monitor-0.1.0.tar.gz 5.8 kB With provenance Details for scrapy_spider_monitor-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scrapy-spider-monitor 0.1.0
File Interpreter ABI Platform Actions
scrapy_spider_monitor-0.1.0-py3-none-any.whl Python 3 none any Details for scrapy_spider_monitor-0.1.0-py3-none-any.whl

Total release size: 12.4 kB

Release files / scrapy_spider_monitor-0.1.0.tar.gz

Download URL scrapy_spider_monitor-0.1.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8be6f8742b5419d70415027e8d8c556c7ed7fd00d4820d4d1afdfee64c01755f
BLAKE2b-256 checksum
How to use checksums
29acac904685558295689e75be732663cb82bf43d9fc0c3770559fb0d3bd9768
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / scrapy_spider_monitor-0.1.0-py3-none-any.whl

Download URL scrapy_spider_monitor-0.1.0-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9fa78428442970522d411bec3bac367412dbf5e83cb7b3916ba08bf88642df5
BLAKE2b-256 checksum
How to use checksums
25b4fe812ef9f179e806df1d990c8e8aa7eb391350fd754043787bddcc05d5d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for scrapy-spider-monitor 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for scrapy_spider_monitor-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page