/zyte-web-data:scrapy-extrafrom zyte-web-data
Provides up-to-date guidance for writing, modifying, and debugging Scrapy spiders, page objects, pipelines, and settings. Use before any Scrapy or web-poet code work to ensure idiomatic patterns and avoid outdated assumptions.
Ships in zyte-web-data. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This file is 171 lines long; read all of them.
You are doing hands-on Scrapy coding: writing or changing spiders, page objects, items, pipelines, settings, or an entire project.
For a new spider, prefer web-poet page objects — isolating extraction keeps the spider focused on crawling and makes it easier to maintain, test, and reuse. How far to go depends on the project:
Never migrate an existing spider to page objects, or add web-poet to a project that doesn't use it, unless asked.
Don't reimplement what Scrapy already does: a spider needs no seen-URL set, since the dupefilter drops duplicate requests on its own.
There is no fixed workflow, no required inputs or outputs. Read the task, read the relevant reference(s) below, and write idiomatic code.
Bundled in ${CLAUDE_SKILL_DIR}/references/ — read only the ones the task
calls for, matched by what you are about to write; most tasks need one:
scrapy.md.web-poet.md.handle_urls, DummyResponse, SCRAPY_POET_DISCOVER) → scrapy-poet.md;
which of the two to inject is the choice that shapes the callback.scrapy-zyte-api.md.For anything beyond these, fetch the official docs rather than guessing —
docs.scrapy.org, web-poet.readthedocs.io, scrapy-poet.readthedocs.io,
scrapy-zyte-api.readthedocs.io, docs.zyte.com. These are LLM-friendly:
replace .html with .md in any URL for Markdown, and see <host>/llms.txt
for a table of contents.
Use uv for all Python execution — never bare python or pip. Install
uv if missing.
cd PROJECT_DIR && uv run scrapy crawl <name>
cd PROJECT_DIR && uv run --with pytest python -m pytest fixtures/
The pytest command is for projects that have a fixtures/ directory; there
is nothing to run without one.
.venv/, uv.lock, *.egg-info and build/ are expected project state, not
temporary files: leave them in place. So are the leftovers of running things —
.pytest_cache/, __pycache__/, the items.jsonl of a test crawl: don't go
looking for them to clean up.
Only when the task needs a fresh project. Use the bundled template — it ships
settings.py with scrapy-poet and Zyte API addons already configured, plus
pages/, spiders/, and fixtures/ directories:
uvx cookiecutter --no-input ${CLAUDE_SKILL_DIR}/assets/project-template \
-o PARENT_DIR project_name=PROJECT_NAME
cd PARENT_DIR/PROJECT_NAME && uv sync
For an existing project, work within it. If dependencies you need are
missing from pyproject.toml, tell the user what's missing and ask before
adding — don't silently rewrite their project.
Whether in a spider callback or a page object @field, use the following
guidelines by default, i.e. unless they contradict other known project
guidelines:
if/else).None for missing data, not "" or False.None.Exception — only the specific exception you expect. The
one exception is per-item extraction when iterating a list of items: there,
catch Exception around each item so one broken item doesn't sink the rest,
and log it with exc_info=True (see web-poet.md → Nested item extraction).extruct for JSON-LD / microdata /
OpenGraph, jmespath for JSON queries, price_parser for prices.BrowserPage, i.e. depend on BrowserResponse — rather than enabling
browserHtml through automap params or custom_settings. Without page
objects, request it per-request via
meta={"zyte_api_automap": {"browserHtml": True}}, on the requests that
need it only (see scrapy-zyte-api.md).Extraction extracts; it never filters. Even if the user asks to exclude or limit results by value, do not put that logic in a page object or extraction method. Filtering, deduplication, and validation belong in the spider or an item pipeline; if the project has neither yet, leave the filter out entirely rather than moving it into the page object. Say so in your summary if the request implied otherwise.
Page objects: verify by running to_item() and comparing to the expected
values — not by testing selectors in isolation, since @field methods,
Returns, and output processing transform the raw selector value into the
final field. Do it as a web-poet fixture checked by pytest: it exercises the
real page object, works the same for HttpResponse and BrowserResponse
pages, and leaves a regression test behind. Build the fixture from whatever
input you have:
uv run scrapy savefixture <page.object.ClassPath> '<url>'.web_poet.testing.Fixture.save (see web-poet.md → Testing
for the snippet — it also covers BrowserResponse).Set each output.json to the hand-verified expected values (correct the
recording from savefixture, or pass them as item= to Fixture.save), then
uv run --with pytest python -m pytest fixtures/ — it re-runs to_item() on every
saved page and fails if a field drifts. See web-poet.md → Testing for the
full loop.
Spiders: run a bounded test crawl and inspect the items, don't trust a
clean exit code. Always bound it with CLOSESPIDER_ITEMCOUNT or
CLOSESPIDER_PAGECOUNT; a handful of items is enough to tell whether the
extraction works, and a full crawl of the site is never part of validating a
spider:
cd PROJECT_DIR && uv run scrapy crawl <name> -s CLOSESPIDER_ITEMCOUNT=5 -o items.jsonl
Read items.jsonl. If a field is consistently null or values look wrong,
the selector is the usual culprit. If the raw HTML turns out to be a
JavaScript shell, switch to browser rendered input (BrowserPage) and
re-save its fixtures — the saved inputs match whatever the page object
depended on when they were recorded. Fix the root cause if it's in scope,
even when it lives in a page object rather than the spider you were asked to
write. After any fix, re-run the crawl and read items.jsonl again to
confirm the field is now populated — a clean exit or the closing stats block
is not evidence the fix worked, and never report field values you have not
seen in the current run's output.
Never present the spider as complete while a field is systematically null
without accounting for it: either fix it, or say in your final answer why not
— the fix is out of scope, or the data genuinely isn't on those pages. Name
the affected field either way.
assets/project-template/cookiecutter.json (opens in a new tab)assets/project-template/{{cookiecutter.project_name}}/pyproject.toml (opens in a new tab)assets/project-template/{{cookiecutter.project_name}}/scrapy.cfg (opens in a new tab)assets/project-template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/__init__.py (opens in a new tab)assets/project-template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/items.py (opens in a new tab)assets/project-template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/pages/__init__.py (opens in a new tab)assets/project-template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/settings.py (opens in a new tab)assets/project-template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/spiders/__init__.py (opens in a new tab)references/scrapy-poet.md (opens in a new tab)references/scrapy-zyte-api.md (opens in a new tab)references/scrapy.md (opens in a new tab)references/web-poet.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
5 skills in this plugin
/scrapeBuild a full-site or multi-page Scrapy spider to get structured data from a website, in a new project or added to an existing one. Do not use for analyzing locally saved HTML, fixing or debugging an existing spider, schema-only or existing-spec work, Scrapy Cloud operations, or advisory questions./scrape-analyze-pageExtract structured data (all available fields with values) from a page saved locally as an HTML file, optionally following a schema. Do not invoke when the user provides a URL. When invoking, pass the user's full request verbatim as args — do not pre-parse file paths and don't rephrase it./scrape-planPlan a web scrape and author a validated extraction spec — explore a detail page, discover fields, confirm the schema, then validate it with more pages, HTML-variant comparison, extracted values, and an optional browser review, and present the plan for approval./zyteZyte account work that has no Zyte MCP tool: credentials (set up, log in, get an API key, or a blocked site); deploying or pushing a project to Scrapy Cloud, and saving a job's full items, log or requests to a file (Zyte MCP results are truncated); Zyte API plan pricing (plans, tiers, discounts, commitments, free credit); how-to and docs questions about any Zyte product or account/billing, from docs.zyte.com. Scrapy Cloud jobs, recorded usage and per-website prices are Zyte MCP tools; use this skill for them only when those tools are missing, to tell the user how to connect the Zyte MCP. NOT for writing/debugging spiders locally (scrapy-extra).npx claudepluginhub zytedata/claude-skills --plugin zyte-web-dataOther plugins' skills for the same job