Scrape a list page, then every detail page: multi-step scraping with pipelines
How to scrape list and detail pages in one run: chain a list extractor and a detail extractor, map the URL field, estimate fan-out cost and read one dataset.
- Published
- Reading time
- 8 min read
- By
- ExtractHub team
- pipelines
- web scraping
- multi-step scraping
- MCP
- tutorial
On this page
Most scraping jobs have two levels. A category or search page lists the items, and the data you want sits on each item’s own page: the full description, the specs, the stock status. To scrape list and detail pages you need the links from the first page, one request per link, and a way to put every record into one dataset without writing the glue yourself.
This post shows how to do it with an ExtractHub pipeline: two released extractors chained together, a list step that outputs URLs and a detail step that runs once per URL. We go through the design, the one field that connects the steps, what fan-out does to the cost, and how to read the results.
How to scrape list and detail pages with a pipeline
A pipeline is a chain of released extractors. The flow is linear:
start URLs ──> step 1 (list extractor) ──url_output_field──> step 2 (detail extractor) ──> dataset
Every start URL runs step 1 once. Every value of step 1’s url_output_field becomes one URL of step 2. Steps run one after the other, stage by stage, and the URLs of one stage run in parallel. By default only the last step’s records go to the dataset.
Each step is an ordinary extractor, the same one you can call through the realtime API, the Batch API or MCP. The pipeline adds the plumbing: reading the URLs out of one result, feeding them to the next extractor, holding credit for the run and collecting the records.
Step 1: two extractors, one per page type
You need one released extractor per page type. If an extractor for the site already exists in the public catalog, you can pin it; otherwise you build it (the extractor builder skill does that with Claude Code).
The list extractor must output the detail URLs. For an illustrative example shop on example.com, the list extractor returns one object per product with a url sub-field, made absolute with the toAbsoluteUrl transform:
{
"name": "products",
"selector": "main [data-testid=\"product-card\"]",
"isArray": true,
"extract": "innerHTML",
"required": true,
"subExtractor": {
"fields": [
{ "name": "title", "selector": "h2", "extract": "textContent", "transforms": ["normalizeWhitespace"] },
{ "name": "url", "selector": "h2 a[href]", "extract": "attributeValue", "attributeName": "href", "transforms": ["toAbsoluteUrl"], "required": true }
]
}
}
The detail extractor reads the product page itself: title, price, SKU, availability. It knows nothing about the list. That split matters: each extractor has its own versions and its own health checks, so a layout change on the detail page is fixed in one place and released as a patch.
Release both and note their pins, for example @you/example-category@1 and @you/example-product@1. Pipeline steps must be pinned, the same rule as the extract API: @1 follows the latest 1.x release, @1.2.3 freezes one version, and @draft runs your own current draft. An unpinned id is rejected with the available majors. Prefer a released major: a draft pin changes what the pipeline does with every edit, and the validator warns about it (draft_pin). The versioning post explains why the major pin keeps a chain from breaking.
Step 2: connect the steps with url_output_field
The chain is written as a list of steps. This is the input of the create_pipeline MCP tool (illustrative example):
{
"name": "Example shop: category -> product",
"input_urls": ["https://www.example.com/category/laptops"],
"steps": [
{ "extractor_id": "@you/example-category@1", "url_output_field": "products[].url" },
{ "extractor_id": "@you/example-product@1" }
],
"output": { "format": "json" },
"limits": { "maxCostPerRun": 1 }
}
url_output_field is required on every step except the last. It names a field of that step’s own output, in path form:
nextPageUrl: one string field;links: an array of strings;products[].url: theurlof every item of theproductslist.
The validator checks the path against the extractor’s output schema. A field that does not exist is an unknown_field error that lists the available fields, URL-looking ones first, so you never have to guess the name.
Relative links and ids
Values do not have to be absolute. A relative link such as /p/123 is resolved against the page it came from. When the list only gives ids or slugs, add a url_template with {value}:
{ "extractor_id": "@you/example-products-api@1", "url_output_field": "items[].id", "url_template": "https://www.example.com/api/products/{value}" }
Each value is URL-encoded before it goes into the template, and a template without {value} is rejected (invalid_url_template). This is how you chain a JSON list endpoint to a JSON detail endpoint when a site has them; a JSON endpoint is not affected by a change of the page layout.
Other step options
include_in_output: truesaves a step’s records in the dataset too, for example the list rows next to the detail records. The dataset groups records per step.skip_if_empty: trueskips a step that received no URLs instead of reporting it.- Fan-out is on by default: every URL from the previous step runs the step once.
The chain form allows up to 10 steps and 100 start URLs per run. Pipelines with branches or merges are built in the dashboard pipeline builder; a chain made through MCP opens and edits there like any other pipeline.
Step 3: validate and estimate before you spend credit
validate_pipeline takes the same input plus url_count (the number of start URLs you plan to run) and saves nothing. It is free and works with a test key. It answers with:
errorsandwarningswith paths such assteps[0].url_output_field;- the resolved steps: version, price tier, price per URL and output fields of each extractor;
- an
estimatewithper_input_url_usd(the sum of the step prices) andestimated_cost_usd.
Read the estimate carefully. It counts one call per step per start URL, which is what a run holds when it starts. It does not know how many links each list page has. The realistic cost per start URL is:
price(list step) + links per page x price(detail step)
A category page with 20 product cards is 1 list call plus 20 detail calls. Two list levels of 20 links each are 400 calls at the third step. Count the links on a saved sample page before you run anything big. The price of each tier is on the pricing section; a detail extractor that works on a plain direct fetch keeps the multiplied part cheap, so check its fetch mode before you chain it.
maxCostPerRun and the fan-out cap
Two limits keep a fan-out from running away:
limits.maxCostPerRun(USD, default 1) caps one run. When a stage would go over it, the run stops with statuscost_limit_exceeded, and what already ran is charged. Set it to your realistic cost plus a margin.- The fan-out cap: a step runs at most 1000 URLs per run. If a step receives more, the first 1000 run in order, the rest are dropped, and the job records a
fan_out_truncatedwarning with the received and dropped counts.
The run holds credit for the estimate when it starts and extends the hold as fan-out grows; unused credit is released at the end. If your balance does not cover the upfront hold, run_pipeline answers insufficient_credit with the required and available amounts, and nothing starts.
Step 4: run it small, then read the results
Create the pipeline with create_pipeline (a live API key; pipelines have no sandbox, so test keys get live_key_required on create, update, run and cancel). Saving is free and returns a pipeline_id and a link to the dashboard builder.
Then run it on one or two start URLs. Running spends credit:
{ "pipeline_id": "<pipeline_id>", "input_urls": ["https://www.example.com/category/laptops"] }
run_pipeline returns a job_id, the status (pending, or queued when your concurrent run slots are busy) and the held estimate. Poll get_pipeline_job every 10 to 30 seconds until the status is completed, failed, cancelled or cost_limit_exceeded. A finished job shows:
stages: one entry per step with the number of runs, counts per status, cost, and the first errors with their URL;actual_cost_usdnext toestimated_cost_usd;warnings, such asfan_out_truncated;results: the first 20 records per step inline (shortened to about 64 KB) and a signeddownload_urlfor the full dataset, valid for one hour. Callget_pipeline_jobagain for a fresh link. Datasets are kept forretentionDays(default 30).
Check the records before you call the pipeline done: every field filled, the URLs right, no repeated items. An empty field on the detail step means the detail extractor needs a fix, not the pipeline: fix the selector, release a patch, and the @1 pin picks it up on the next run. A run you started by mistake can be stopped with cancel_pipeline_job: a queued job costs nothing, and a running one stops before its next step.
What a failed detail page costs
A step pays its price once per URL, succeeded or failed, once the scraping service was billed for the fetch: a blocked page, a target 404 or a required field that came back empty all count. Failures before any billable fetch are free, and so are failed direct fetches. Target-side errors are retried once inside the step, so a short hiccup does not fail the item. Failed calls count toward maxCostPerRun, which is one more reason to test small first.
Pagination: what a chain cannot do
A chain has no loops, so a step cannot feed itself the next page. For “every page of a category” you have two options:
- Predictable page URLs: pass them all as start URLs (
?page=1to?page=5, up to 100 per run). Each one runs the list step and fans out to its products. - Unpredictable next links: run the first page, read
nextPageUrlfrom the list records (save them withinclude_in_output: true), and start the next run from it.
Two list steps in a row (a category page whose nextPageUrl feeds a second list step) reach one extra page only, so they are rarely worth it.
Let an agent build the pipeline
Everything above is also what the ExtractHub pipeline builder skill tells an agent to do. Install it next to the extractor builder skill in Claude Code:
git clone https://github.com/extracthub-io/extracthub-pipeline-builder ~/.claude/skills/extracthub-pipeline-builder
With the MCP server connected, ask for the whole job: “Scrape every product of this category and each product page into one dataset.” The agent finds or builds one extractor per page type, takes url_output_field from the output schema instead of guessing it, validates the chain, works out the fan-out cost and tells you before the first run. It runs one small job only with your OK, checks the records, and turns a schedule on only when you agree to the cron and the cost per run.
For a recurring scrape, the same pipeline takes a cron schedule and webhooks on completion; a schedule is saved off unless it is explicitly activated.
FAQ
How do I scrape a list page and then every detail page it links to?
Build two extractors, one for the list page that outputs the detail URLs and one for the detail page, then chain them in a pipeline. The list step's url_output_field (for example products[].url) names the field whose values become the URLs of the next step.
What if the list page gives ids instead of URLs?
Add a url_template with {value} to the list step, for example https://www.example.com/p/{value}. Each id is URL-encoded and put in the template. Relative links work without a template: they are resolved against the page they came from.
How many detail pages can one pipeline run scrape?
One step runs at most 1000 URLs per run. When a step receives more, the first 1000 run, the rest are dropped and the job shows a fan_out_truncated warning. Split large jobs into several runs with fewer start URLs.
How much does a list and detail pipeline cost?
Each step call costs its extractor's price per URL, so one start URL costs one list call plus one detail call per link on the page. The upfront estimate counts one call per step; fan-out multiplies it, and maxCostPerRun stops a run before it spends more than you set.
Can I scrape every page of a paginated category?
A chain has no loops, so a step cannot feed itself. When the page URLs are predictable, pass them all as start URLs; otherwise run the first page, read nextPageUrl and start the next run from it.
Related
- Build a job listings scraper: list pages, JobPosting JSON and dedupe by URL: Build a job listings scraper that returns structured JSON: job URLs from list pages, JobPosting fields and ISO dates from each job page, and dedupe by URL.
- Build a price monitoring scraper: product fields, daily runs and change detection: Build a price monitoring scraper: a product extractor with typed prices, daily batch or scheduled runs, a signed webhook and change detection in your code.
- Use ready-made web scrapers instead of writing one: find, check and pin a public extractor: Use ready-made web scrapers instead of writing one: find a public extractor, read its fields, price tier and health, pin a version and call it with your key.
- Agent skill: install the extractor builder skill for Claude Code
- MCP server: connect Claude Code, Cursor or any MCP client
- API reference: realtime extract, async jobs and the Batch API
- Web scraper catalog: public extractors you can call today