Web Scraper — CSS Selector & Data Extractor avatar

Web Scraper — CSS Selector & Data Extractor

Pricing

from $0.35 / 1,000 pages

Go to Apify Store
Web Scraper — CSS Selector & Data Extractor

Web Scraper — CSS Selector & Data Extractor

Extract CSS selectors as text, HTML, attributes, tables or counts. Only accepted pages enter the results dataset; failed or empty pages are retained as diagnostics.

Pricing

from $0.35 / 1,000 pages

Rating

0.0

(0)

Developer

Murat Uzun

Murat Uzun

Maintained by Community

Actor stats

0

Bookmarked

30

Total users

14

Monthly active users

18 hours ago

Last modified

Features

Limited permissions

Share

What is CSS Selector Extractor (any page, any field)?

CSS Selector Extractor (any page, any field) is an Apify Actor that turns a list of URLs and a list of CSS selectors into structured data — no scraper to write, no browser to configure. Give it a page and tell it "get the text at .price" or "get the href at a.download-link" and it returns one clean row per accepted page with exactly the values those selectors matched (on a list page, that row carries an items array with one object per product, post or listing). It is the generic "scrape this bit of this page" tool people reach for before writing a custom Cheerio or Playwright script, and it works on any HTML page — product pages, blog posts, directories, documentation, internal tools — using plain HTTP requests, with a headless-browser fallback only for JavaScript app pages that would otherwise return nothing (renderFallback). Runs on Apify's schedule, webhook and API infrastructure, so checking the same selectors across a list of pages on a timer is a five-minute setup.

Price: $0.50 per 1,000 accepted pages ($0.0005 per page; $0.35 per 1,000 on Gold and above). Failed, empty and 404 pages are free.

New in 0.2: scrape list pages (one object per product card, job row or search result with itemSelector), follow pagination or detail links (linkSelector + maxPages), read whole sites from their sitemap (sitemapUrls, gzip and nested indexes handled) and get page metadata + JSON-LD (includeMetadata) — all still one billed page per row, no browser. Successful output fields remain compatible.

Restart-safe in 0.32: if the Apify platform moves a run to another server mid-run (a host migration), the restarted run skips every page the first attempt already saved, so no page is saved or charged twice. Before 0.32 the restarted run began again from the first URL (seen on 28 Nov 2026: 4 URLs → 7 rows).

Result policy in 0.30.4+: failed requests, wholly empty extractions and pages missing a requested requiredFields value are saved as DIAGNOSTIC-* records, outside the charged results dataset. A requested count of 0 is still a valid result. Runs where the pages loaded but nothing matched, every URL returned 404/410, or no URL has a domain that exists (DNS ENOTFOUND, usually a typo), remain SUCCEEDED with no_results and the reason (OUTPUT.zeroResultReason: NO_MATCHES, PAGE_NOT_FOUND, DOMAIN_NOT_FOUND) in OUTPUT and the terminal message. Invalid input (no usable URL or selector) ends SUCCEEDED with INPUT_ERROR before any request. Only a run where every page failed at the source (blocked, other HTTP errors, network) and nothing was delivered ends FAILED with SOURCE_FAILED. The actor-start fee may still apply.

Start with one page

Paste this into the Actor's JSON input and set Maximum cost per run before starting:

{
"urls": ["https://example.com/"],
"selectors": [{ "name": "pageTitle", "selector": "title", "type": "text" }],
"maxPages": 1,
"firstMatchOnly": true
}

In Output, check that error is empty, matchCounts.pageTitle is positive and fields.pageTitle contains the page title. A page with no extracted values needs a selector change and goes to diagnostics; a requested count of 0 remains valid data. If the page is a JavaScript app (React, Vue, Angular) and the data only appears after JavaScript runs, give the run 1024 MB memory: renderFallback (on by default) opens such a page once in headless Chromium and runs your selectors again — see JavaScript pages.

Use the website-fields starter and output checklist for a downloadable input and integration template. Once the first page works, replace the URL and selector with your target, test one page again, then increase the batch. For recurring monitoring, schedule that tested input and keep the same field names so downstream tables remain compatible.

What data does CSS Selector Extractor extract?

For every accepted URL, the Actor runs each configured selector against the page and returns:

FieldTypeDescription
url, finalUrlstringThe input URL and the URL after following redirects
statusCode, contentTypenumber, stringHTTP status code and Content-Type header of the fetched page
fieldsobjectOne key per selector name — a string, an array of strings, a number for count, or row objects for table
matchCountsobjectOne key per selector name — how many DOM nodes that selector actually matched
htmlSizeBytesnumberSize of the fetched HTML in bytes
usedProxybooleanWhether this URL needed Apify Proxy to load
errorstringSet when the URL could not be fetched or parsed; every other field but url and scrapedAt stays null
scrapedAtstringTimestamp of the fetch (ISO 8601 UTC)
items, itemCountarray, numberItem mode only: one object per element matching itemSelector, and how many matched in total
metadataobjectWith includeMetadata: title, description, canonical URL, language, Open Graph tags and parsed JSON-LD
foundOnstringWith linkSelector: the page whose link led here (null for the start URLs)

How to use CSS Selector Extractor

  1. Fill URLs with one page per line — product pages, articles, directory listings, anything with static HTML.
  2. Fill Selectors with a JSON array of {"name", "selector", "type"} objects. type is one of text (element text), html (element's outer HTML), attr (an attribute value — add "attribute":"href" or similar) or count (how many nodes matched, no value extraction). Short forms work too: ["h1", "p.price"] (text fields named after the selector) and Scrapy-style a.more::attr(href) or h1::text.
  3. Leave First match only on to get one value per selector, or turn it off to get every match as an array (capped by Max matches per selector).
  4. Click Start and export the dataset as JSON, CSV, Excel or HTML from the Output tab — one row per accepted page, ready to join, chart or feed into another system.

Example input

{
"urls": ["https://example.com/"],
"selectors": [
{ "name": "pageTitle", "selector": "title", "type": "text" }
],
"firstMatchOnly": true,
"trimWhitespace": true,
"maxPages": 1
}

Example output

{
"url": "https://example.com/",
"finalUrl": "https://example.com/",
"statusCode": 200,
"contentType": "text/html; charset=utf-8",
"fields": {
"pageTitle": "Example Domain"
},
"matchCounts": {
"pageTitle": 1
},
"htmlSizeBytes": 577,
"usedProxy": false,
"scrapedAt": "2026-10-28T14:21:40.381Z",
"error": null
}

Successful extraction appends a warnings array: { "field": "price", "reason": "no_match" } for an unmatched selector, or empty_value for an empty extracted value. The field name follows your selector. Valid values, including text "0" and numeric count 0, produce no warning. Item mode collects unique field/reason pairs across extracted items. Warnings are advisory; existing acceptance rules still apply. Failed requests retain their existing error shape without this optional array.

A URL that fails to load or parse is retained in the default key-value store as a DIAGNOSTIC-* record, not a result row. Open Quality report in Output for counts and the first diagnostic key, or use Storage → Key-value store → Diagnostics. OUTPUT.status is running during processing, then complete, partial, or no_results. The additive partial, stoppedForTime, chargeLimitReached, and inputLimited flags distinguish rejected pages and bounded stops; existing counts and dataset row fields are preserved. A count of zero explicitly requested by a selector is still accepted data. Mixed batches keep successful results; a valid batch with no accepted results remains SUCCEEDED without a result event, including sitemap-only runs that discover zero page URLs. OUTPUT.status and the terminal message say no_results; diagnosticRows and diagnosticReasons report rejection counts and reasons. OUTPUT.zeroResultReason says why a run has no results: INPUT_ERROR, NO_MATCHES, PAGE_NOT_FOUND, DOMAIN_NOT_FOUND (SUCCEEDED) or PARTIAL_SOURCE_FAILURE / SOURCE_FAILED (FAILED). A network error keeps its cause in the diagnostic error (for example fetch failed (ECONNREFUSED)). Storage failures are not converted into empty successful runs. Budget/time stops remain bounded exits and are explicitly reported as incomplete.

zeroResultReasonRun endsWhat happenedWhat to do
INPUT_ERRORSUCCEEDEDNo usable URL or selector; no request was madeFix the input named in the status message
NO_MATCHESSUCCEEDEDPages loaded, selectors matched nothingCheck the selectors in DevTools; try renderFallback: "auto" with 1024 MB
PAGE_NOT_FOUNDSUCCEEDEDEvery URL returned 404/410Check the URLs
DOMAIN_NOT_FOUNDSUCCEEDEDNo URL has a domain that exists (DNS ENOTFOUND)Check the domains for typos
PARTIAL_SOURCE_FAILUREFAILEDSome pages failed at the source, the rest matched nothingOpen a DIAGNOSTIC-* record; try proxyMode: "always"
SOURCE_FAILEDFAILEDEvery page was blocked, errored (403/429/5xx) or unreachableTry proxyMode: "always" or check the site

None of these generate a result charge.

Scrape list pages, follow pagination and read sitemaps

List pages (item mode). Set itemSelector to the repeated element; every selector is then searched inside each item, and the row carries an items array — up to 1,000 items per page for the price of one page.

{
"urls": ["https://books.toscrape.com/"],
"itemSelector": "article.product_pod",
"selectors": [
{ "name": "title", "selector": "h3 a", "type": "attr", "attribute": "title" },
{ "name": "price", "selector": ".price_color", "type": "text" }
],
"linkSelector": "li.next a",
"maxPages": 3
}

Output: 3 rows (the start page plus two "next" pages), each with itemCount: 20 and items like { "title": "A Light in the Attic", "price": "£51.77" }. Rows reached by a followed link carry foundOn.

Pagination and detail pages. linkSelector follows any links you point it at — a.next for pagination, a.product-link for detail pages — staying on the same domain unless sameDomainOnly is off, filtered by an optional urlPattern regex, and never beyond maxPages (default 100).

Whole sites from a sitemap. Give sitemapUrls (e.g. https://example.com/sitemap.xml) instead of, or together with, urls. Sitemap indexes, nested sitemaps and .xml.gz files are expanded automatically; urlPattern keeps only the pages you want (e.g. /products/).

Numbered pages without a next link. urlTemplate with pageRange generates the page URLs up front: "https://books.toscrape.com/catalogue/page-{page}.html" with {"from": 1, "to": 2} fetches pages 1 and 2 (20 prices each in our cloud test). Use step for offset-style URLs such as ?start={page} with {"from": 0, "to": 100, "step": 20}. Generated URLs are not capped by maxPages (only by the 10,000 limit and your max total charge).

HTML tables in one field. A selector with "type": "table" returns the matched <table> (or the first table inside the matched element) as an array of row objects keyed by its header row — e.g. { "name": "customers", "selector": "#customers", "type": "table" } on the w3schools tables page gave 6 rows like { "Company": "Alfreds Futterkiste", "Contact": "Maria Anders", "Country": "Germany" }. Blank headers become column_N, repeated ones get _2, and colspan cells are repeated so columns stay aligned. Up to 1,000 rows per table.

Coming from Google Sheets IMPORTHTML or IMPORTXML? Paste the formula as it is — =IMPORTHTML("https://example.com/standings", "table", 1) — into URLs: the one link inside it is used as the URL. For the table itself add the selector { "name": "table", "selector": "table", "type": "table" } (first table on the page; use the table's id or class for another one). XPath expressions from IMPORTXML can go straight into selector; simple ones are converted to CSS. Runs can follow pagination and be scheduled. When no selector matches but the page has tables, the run's status message says how many and gives the table selector to add.

Headers and cookies. headers (e.g. {"Accept-Language": "de-DE"}) and cookies (e.g. [{"name": "session", "value": "…"}] or ["theme=dark"]) go with every page request — for pages behind a login cookie, an API key header or a locale switch. In our cloud test an echo endpoint received Accept-Language: de-DE, a custom header and Cookie: session=abc123; theme=dark. Header and cookie values are never written to the run log, but they are stored in the run input like any other field.

Metadata and JSON-LD. includeMetadata: true adds metadata with title, description, canonical URL, language, Open Graph tags and every parsed schema.org JSON-LD block — product prices, ratings, article dates and organization details without writing a selector.

JavaScript pages (renderFallback)

Most pages are read as plain HTML — fast and cheap. A page built in the browser by JavaScript (a React/Vue/Angular "app shell" with an empty <div id="root">) has nothing for your selectors in that HTML. With renderFallback: "auto" (the default) the Actor notices exactly that case — no selector matched and the HTML looks like an app shell — opens that one page in headless Chromium, waits for its network to settle and runs your selectors again on the rendered page. Every other page never touches a browser.

  • Why auto is the default: it only kicks in on pages that would otherwise return nothing, so static pages stay as fast as before, and you do not have to know in advance which pages need a browser.
  • Price: unchanged. A rendered page that matches is one result like any other; a page that still matches nothing stays a free diagnostic.
  • Memory: Chromium needs 1024 MB run memory. The default run memory is 256 MB (512 MB before 0.31; an HTTP-only run needs no more), where the browser is never started: the run finishes normally, OUTPUT shows renderSkipped: "LOW_MEMORY" and renderNeededPages, and the status message tells you to rerun with 1024 MB.
  • Output: a rendered row has rendered: true; OUTPUT has renderFallback, renderedPages, renderFailedPages.
  • always renders every page (slower; for sites where the static HTML is misleading); never turns the browser off.

Use it from code, n8n or Make

Call the Actor over the Apify API and use the rows in your own pipeline. Replace YOUR_APIFY_TOKEN with your token from the Apify Console.

cURL (synchronous: the response is the dataset rows):

curl -X POST "https://api.apify.com/v2/acts/webdatatools~css-selector-extractor/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"urls":["https://books.toscrape.com/"],"selectors":[{"name":"title","selector":"h1","type":"text"}]}'

Python (pip install apify-client):

from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("webdatatools/css-selector-extractor").call(run_input={
"urls": ["https://books.toscrape.com/"],
"selectors": [{"name": "title", "selector": "h1", "type": "text"}],
})
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
print(row["url"], row["fields"])

JavaScript (npm install apify-client):

import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const run = await client.actor('webdatatools/css-selector-extractor').call({
urls: ['https://books.toscrape.com/'],
selectors: [{ name: 'title', selector: 'h1', type: 'text' }],
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);

n8n and Make: use the HTTP Request module (n8n) or the HTTP "Make a request" module (Make) with the cURL call above as a POST with a JSON body. The response is an array of rows, one per page, ready for the next step.

At a glance: this Actor and the other scrapers in the Store

CSS Selector Extractorapify/cheerio-scraperapify/web-scraperapify/ai-web-scraper
How you describe the dataJSON list of {name, selector, type}JavaScript pageFunctionJavaScript pageFunctionNatural-language prompt
Price$0.0005 per page ($0.50 per 1,000; lower on higher plans)Free, platform usage onlyPlatform usage (browser)$0.009 per page
Tables into rowsBuilt in (type: "table")Write codeWrite codeNot compared

Prices as listed on each Actor's Store page; ours updated 21 November 2026, the others checked 11 October 2026.

Input parameters

ParameterTypeDefaultDescription
urlsarray["https://data.chimeramind.com/start/website-fields/"]One URL per line to fetch and run the selectors against
selectorsarray (JSON)[{"name":"title","selector":"h1","type":"text"}]{name, selector, type, attribute?} objects; type is text, html, attr, count or table; capped at 25 entries
requiredFieldsarray[]Selector names that must contain values; a missing required value sends the page to diagnostics without a result event
firstMatchOnlybooleantrueReturn only the first match per selector; off returns every match as an array
maxMatchesPerSelectorinteger20Most values returned per selector when firstMatchOnly is off (1-500)
trimWhitespacebooleantrueCollapse whitespace runs and trim ends of extracted text/attr values
maxConcurrencyinteger5Parallel page fetches (1-20)
proxyModestringautoauto tries every URL directly first and only switches to Apify Proxy after a block is detected; always and never force one path
renderFallbackstringautoauto renders only a page whose HTML matched nothing and looks like a JavaScript app; always renders every page; never stays plain HTML. Needs 1024 MB memory
proxyConfigurationobjectResidential proxyWhich Apify Proxy group proxyMode uses when a request needs the proxy
itemSelectorstring—Repeated element for list pages; selectors are searched inside each match and returned as items
maxItemsPerPageinteger200Most items returned per page in item mode (1-1000); itemCount always reports the full number
linkSelectorstring—Links to follow (pagination or detail pages); each followed page is one more row
sitemapUrlsarray—Sitemap or sitemap-index URLs whose pages are added to the run
urlPatternstring—Regular expression that followed links and sitemap URLs must match
maxPagesinteger100Total page cap when following links or reading sitemaps (plain URL lists are not capped by it)
sameDomainOnlybooleantrueOnly follow links on the same host as the page they were found on
includeMetadatabooleanfalseAdd title, description, canonical, language, Open Graph and JSON-LD per page
urlTemplatestring—URL with a {page} placeholder; one URL per number in pageRange is added (up to 10,000)
pageRangeobject—{"from": 1, "to": 10, "step": 1} for urlTemplate; inclusive, from defaults to 1
headersobject—Extra HTTP headers for every page request; a User-Agent here replaces the default
cookiesarray—["name=value"] or [{"name", "value"}] (browser cookie export); sent as one Cookie header

Pricing

CSS Selector Extractor uses pay-per-event pricing: $0.50 per 1,000 accepted pages ($0.0005 per page) on the free plan, $0.45 on Bronze, $0.40 on Silver and $0.35 on Gold and above, plus a negligible actor-start fee. Pages rendered with the JavaScript fallback cost the same. Extracting five selectors from 100 URLs costs about five cents, when at least one requested value is returned (or a requested count is 0), whether one selector matches or five do — the price is per page, not per field, and in item mode a page with 200 products is still one page. Set Maximum cost per run and the Actor stops at what the budget covers instead of overspending — including pages found by following links or reading sitemaps.

CSS Selector Extractor vs. writing your own scraper

A one-off Node or Python script with Cheerio or BeautifulSoup can do the same extraction, but it means writing fetch/retry/timeout logic, a proxy fallback, whitespace cleanup and a dataset writer from scratch for every new site. This Actor already handles retries, direct-first proxy escalation on a block, and a guaranteed one-row-per-page output shape — describe the fields once as a small JSON list and get a typed dataset back, schedulable and API-callable without touching code.

Using CSS Selector Extractor with AI agents and MCP

CSS Selector Extractor is pay-per-event with limited permissions — the two requirements for an Actor to be callable through the Apify MCP server at mcp.apify.com. An agent that needs one specific value off a page (a price, a title, a status, a download link) can call this Actor directly with a urls list and a selectors array instead of fetching and parsing HTML itself, and gets back a typed row with the value already extracted, trimmed, and counted.

Forgiving input. Agents rarely send the exact schema, so the Actor accepts the common variants instead of failing: selectors as plain strings or a {"field": "selector"} map, Scrapy ::text / ::attr(name) suffixes, www.example.com/page without https://, and startUrls: [{"url": ...}] or url instead of urls. Simple XPath is translated to CSS (//h1 → h1, //a/@href → attribute href of a, //div[@class="price"], //*[@id="main"], [contains(@class,"x")], [starts-with(@href,"/p")], li[2], /text()); each translation is logged and listed in OUTPUT.xpathConverted. XPath without an exact CSS equivalent (unions, axes, other functions) or broken CSS is skipped with the reason in the log and in OUTPUT.invalidSelectors; if nothing usable is left, the run ends SUCCEEDED with INPUT_ERROR and that reason as its status message, before any page is fetched and without a result charge.

Short timeouts return partial results. Each accepted row is saved to the dataset as its page is processed; rejected pages go to diagnostics. When the run's timeout is close (the last 10 s, or 5 % of a longer run, at most 2 min) the Actor starts no new pages and the run ends SUCCEEDED — not TIMED-OUT — with a status message such as partial: 495 result page(s), 2 diagnostic page(s). Stopped early before the run timeout; unfinished pages may remain. URLs it never reached generate no result event; platform usage and the start fee may still apply; read the run's statusMessage to tell a complete result from a partial one, and re-run the remaining URLs.

Sizing a run. Speed depends on the target site: a fast site gives roughly 10–20 pages per second at the default maxConcurrency of 5 (495 docs.apify.com pages in about 30 s in our test), a slow or proxied one far less. Give large lists a timeout of several minutes, or raise maxConcurrency. maxTotalChargeUsd caps the cost — the Actor processes only as many pages as the budget covers and says so in the status message.

Need bulk volume or a custom scraper?

Need a fixed monthly price, a large recurring run, extra output fields, or a scraper for a site this Actor does not cover? Open an issue on this Actor's Issues tab and include: the target site or URL pattern, the expected volume per run and how often you run it, and the output fields you need. We reply there.

FAQ

Does this use a headless browser? Only when it has to. Every page is fetched with plain HTTP and parsed with Cheerio first. With renderFallback: "auto" (default) a page where no selector matched and whose HTML looks like a JavaScript app shell is opened once in headless Chromium (needs 1024 MB run memory); always renders every page, never turns it off.

What happens if my selector matches nothing? Optional fields can be null in an otherwise useful result. If no requested field has a value, the page goes to diagnostics instead of generating a result event. A requested count of 0 is a valid value. Use requiredFields, e.g. ["price"], when a specific field must be present; in item mode every returned item must satisfy it.

What does type: "count" do? It returns how many elements the selector matched as a number, ignoring firstMatchOnly — useful for "how many products/comments/results are on this page" without extracting any text.

Why is my attr field null even though the element exists? Either attribute was left out of that selector's definition, or the matched element simply doesn't have that attribute set — both return null rather than throwing.

Why did a site return blocked or empty content? Some sites answer bot traffic with a challenge page even at HTTP 200. With proxyMode set to auto (the default), the Actor detects that content and retries the rest of the run through Apify Proxy automatically — no proxy spend unless a block is actually detected. Since 0.31, proxied pages reuse one proxy session (a new one after a block, rate limit, error or a page slower than 5 s) and every request accepts Brotli as well as gzip, so a proxied run transfers fewer bytes per page.

Can a run charge the same page twice? Not since 0.32. Pages finished before a platform host migration (or before a run is resurrected) are kept in the run's key-value store under CRAWL_PROGRESS; the restarted run skips them, follows their saved links when crawling, and reports their counts in OUTPUT. A URL you list twice in urls is still fetched (and billed) twice, as before.

Is this legal to run? Extracting publicly visible page content for your own use is common practice, but you are responsible for complying with the target site's Terms of Service and applicable law (e.g. robots.txt, copyright, personal-data rules) for your specific use case.

Can it crawl a whole site? Yes — give a sitemap in sitemapUrls, or a linkSelector such as a[href] with maxPages. For full-text Markdown of every page rather than specific fields, use Website to Markdown.

What happens to a page bigger than 10 MB? It is not read in full or parsed. Its diagnostic record carries error with the reason, and statusCode still shows what the server answered. Rate-limited (429) and server-error (5xx) answers are retried with exponential backoff, honouring Retry-After, and each URL gets at most 45 seconds across all of its attempts.

What are the limitations? JavaScript rendering needs 1024 MB run memory and renders one page at a time (no clicks, scrolling or logins inside the browser), up to 25 selectors per run, up to 1,000 rows per table field, up to 500 matches returned per selector even when firstMatchOnly is off, and up to 1,000 items per page in item mode. A failing URL produces a diagnostic record with the reason in error, outside the result dataset.

Need to know when the section you extract here changes? Page & Price Watch watches one CSS-selected section of a public page (or its readable text or price) on a schedule and emails you only when that value changes, so rotating banners and timestamps do not trigger alerts.

Support and feedback

Found a page shape or selector edge case it should handle better? Open an issue on the Issues tab.

Part of the webdatatools web-intelligence suite — every Actor is pay-per-event, reads public data without a login, and returns one clean row per entity:

Browse the whole suite at webdatatools, or call ten of these Actors straight from Claude, Cursor or Cline with the webdatatools MCP server.

Website & domain intelligence

Content for AI, LLMs and RAG

Search, video and social

Leads, jobs and company data

Developer, app and research data

Feedback

Did it help? A quick review helps a lot: https://apify.com/webdatatools/css-selector-extractor/reviews