ワンクリックで
scrape-define
Create a new extraction spec from a URL — explore a detail page, discover fields, quick schema approval
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Create a new extraction spec from a URL — explore a detail page, discover fields, quick schema approval
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Extract structured data (all available fields with values) from a page saved locally as an HTML file, optionally following a schema. Use this skill only to process already downloaded files. 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.
Analyze an HTML page to produce field extraction instructions for code generation
Generate web-poet page object code from per-page extraction analyses
Generate web-poet page object code from an extraction spec
Generate a Scrapy spider that wires page objects together
Generate an HTML review page for schema and extracted data verification
| name | scrape-define |
| description | Create a new extraction spec from a URL — explore a detail page, discover fields, quick schema approval |
| argument-hint | [url] [what to extract] |
| allowed-tools | Agent, Skill, Bash, Read, Write, AskUserQuestion |
You are helping the user quickly define what to extract from a website. Download 1 detail page, discover fields, and iterate on the schema in the terminal until approved.
Read ${CLAUDE_SKILL_DIR}/../scrape/references/python-environments.md.
The output is a draft spec folder with an approved schema and values (no stored pages — those are Stage 2's job). It can be expanded with /scrape-spec (more pages, variant comparison, navigation).
Hard constraints — never violate these:
/scrape-explore-site subagent; field discovery is handled by the /scrape-analyze-page subagent. The main agent only orchestrates and consumes their outputs.raw.html, rendered.html, *.cleaned.html, and any other saved page HTML. You may check whether a file exists, but you MUST NOT open it, print it, grep it, parse it, or run extraction scripts against it from the main agent./scrape-analyze-page as a subagent before building any schema. Building a schema from raw HTML without first running that subagent is a critical error./scrape-analyze-page, do NOT read HTML files, run clean_html.py, extract_metadata.py, or any inline parser code, even if the agent response suggests continuing unrelated work. Wait for the subagent to complete, then read only its saved JSON output.From $ARGUMENTS, determine:
Ensure site_name is unique:
BASE="books-toscrape" # your derived site_name
NAME="$BASE"
N=2
while [ -d ".scrape/$NAME" ]; do NAME="${BASE}-${N}"; N=$((N+1)); done
echo "$NAME"
Create the folder structure ({data_type} must be singular, e.g. book not books):
.scrape/{site_name}/
{data_type}/
.scrape/.work/{site_name}/
explore/
analyze-page/
Ask the user how to obtain a detail page via AskUserQuestion:
Provide a URL — "I'll paste a detail page URL (e.g. a product page)."Explore the site — "Find one automatically from the target URL."If the user picks "Provide a URL": follow up with a plain-text prompt — "Paste the detail page URL." — and wait for their next message. Then download that page using download.py:
uv run ${CLAUDE_SKILL_DIR}/../scrape-explore-site/scripts/download.py --skill scrape-define --log-file .scrape/.work/{site_name}/explore/download.log <<'EOF'
[{"url": "USER_URL", "output_dir": ".scrape/.work/{site_name}/explore/pages/detail-1", "page_type": "detail"}]
EOF
If the user picks "Explore the site": Use a subagent to run the /scrape-explore-site skill with minimal counts. The subagent prompt should be:
Run /scrape-explore-site {target_url} .scrape/.work/{site_name}/explore 1 0
This downloads the homepage + 1 detail page into .scrape/.work/{site_name}/explore/pages/.
If the site is blocked, suggest Zyte. Only invoke /scrape-zyte-login if the user agrees. After it returns, re-run the scrape-explore-site subagent above.
Use rendered.html for analysis. If it doesn't exist, fall back to raw.html. Choose between them with a file-existence check only; do not read, grep, print, clean, or parse either HTML file in the main agent.
Run a subagent with the analysis skill. The subagent prompt MUST start with /scrape-analyze-page, and the subagent must invoke that skill; it is not acceptable for the main agent to run clean_html.py, extract_metadata.py, sed, grep, cat, or inline Python/lxml parsing as a substitute.
Agent(description="analyze detail-1 rendered", prompt="/scrape-analyze-page Extract data from .scrape/.work/{site_name}/explore/pages/detail-1/rendered.html and save it into .scrape/.work/{site_name}/analyze-page/detail-1.rendered.json")
After starting the analysis subagent, wait for it to finish. If the expected JSON file is not present, retry the /scrape-analyze-page subagent or report a blocker. Do NOT create the analysis JSON yourself from HTML.
Read the analysis result from .scrape/.work/{site_name}/analyze-page/detail-1.rendered.json. Do not inspect the downloaded page HTML or any cleaned HTML after the analysis subagent returns; the JSON result is the only allowed field-discovery input for the main agent.
From the analysis result, build a JSON Schema:
str → string, float → number, int → integer, list → array, dict → objectdescription for each field (infer from context)"source": "requested", others as "source": "discovered"Present the schema with values in the terminal. Group by requested/discovered:
Found {N} fields on {detail_page_url}:
Requested:
title (string): "A Light in the Attic"
price (string): "£51.77"
Discovered:
rating (integer): 3
category (string): "Poetry"
description (string): "It's hard to imagine a world without..." (2340 chars)
upc (string): "a897fe39b1053632"
image_url (string): "https://books.toscrape.com/media/cache/fe/72/..."
Wait for user response. The user can:
Loop until the user approves. Re-display the schema after each change.
Write .scrape/{site_name}/{data_type}/spec.json. The output MUST be valid JSON Schema (draft/2020-12) — use exactly the structure shown below. Do NOT invent a custom format (e.g. a plain array of field objects). Include examples in each schema field — the user-approved value (with any corrections). This tells Stage 2 the expected format. Include examples for all fields. Truncate values longer than 200 chars with "..." — keep enough to show the format.
{
"url": "https://books.toscrape.com",
"data_type": "product",
"html_variant": "rendered",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "Book title as displayed on the detail page",
"source": "requested",
"examples": ["A Light in the Attic"]
},
"price": {
"type": "string",
"description": "Book price without currency symbol",
"source": "requested",
"examples": ["51.77"]
}
}
}
}
Write .scrape/{site_name}/spec.json:
{
"url": "https://books.toscrape.com",
"data_types": ["{data_type}"]
}
Note: data_types only lists the primary data type. /scrape-spec adds "navigation" later.
Spec draft saved to .scrape/{site_name}/:
{data_type}: {N} fields
Run /scrape-spec .scrape/{site_name} to explore more pages and validate.