# No-Code CSS Selector Web Scraper — URL + Field Map to JSON (`leadsbrary/selector-map-web-scraper`) Actor

No-code web scraper with CSS selectors: give start URLs and a field map (CSS or XPath, attribute, regex, type) and get structured rows with pagination and detail pages. Export JSON, CSV, Excel. From $1 per 1,000 results.

- **URL**: https://apify.com/leadsbrary/selector-map-web-scraper.md
- **Developed by:** [Alexandre Manguis](https://apify.com/leadsbrary) (community)
- **Categories:** Developer tools, Automation
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## No Code Web Scraper CSS Selector — URL + Field Map to JSON

### What does this Actor do?

This **no code web scraper CSS selector** tool turns any public, server-rendered web page into structured data. You give it start URLs and a *field map* (a field name → a CSS or XPath selector, plus optional attribute, regex and type). It returns one clean JSON row per item, and can follow "next page" links or a page-URL pattern, and open each item's detail page for extra fields. No code and no custom page function to write. Results can be exported as JSON, CSV, Excel, XML or HTML from the Apify dataset.

### Use cases

- Marketers and analysts who need a product, listing or directory table from a site without writing a scraper.
- Developers who want a quick, declarative extractor they can call from an API or an automation tool.
- Price monitoring, catalogue extraction, quote/article lists, job or event listings, directory pages.
- Prototyping selectors on a single page before building something bigger.

### Features

#### What you can configure

- **Field map**: CSS selectors (or XPath when the selector starts with `/`), extract `text`, `html` or an attribute.
- **Cleaning**: optional regex (first capture group) and type conversion: `string`, `number`, `integer`, `boolean`, `url` (made absolute).
- **Multiple values**: `all: true` returns a list (for example all tags of an item).
- **Pagination**: a "next page" CSS selector, or a URL pattern containing `{page}`, limited by `maxPages`.
- **Detail pages**: follow a link inside each item and read extra fields from the detail page.
- **Missing-field report**: each row lists `missingFields`; a `SELECTOR_REPORT` record gives hints when a selector matches nothing.
- **Polite by default**: configurable delay between requests, `maxResults` cap, optional Apify Proxy.
- Public pages only: `Cookie` and `Authorization` headers and private/local hosts are refused.

#### Limitations

- It reads the HTML the server sends. Pages that build their content with JavaScript are not supported.

### Input

#### Input fields

| Field | Required | Description |
|---|---|---|
| `startUrls` | yes | Public http(s) pages to scrape. |
| `fields` | yes | List of `{name, selector, extract, attribute, regex, type, all, selectorType}`. Evaluated inside each item. |
| `itemSelector` | no | CSS selector of each repeated item. Empty = each page is one item. |
| `nextPageSelector` | no | CSS selector of the "next page" link. |
| `pageUrlPattern` | no | URL with `{page}`, used from page 2; stops at the first empty page. |
| `maxPages` | no | Pages per start URL (default 5). |
| `detailLinkSelector` | no | Link inside each item to open as a detail page. Needs `detailFields`. |
| `detailFields` | no | Fields read on the detail page (names must differ from `fields`). |
| `maxResults` | no | Stop after this many rows (default 100). Also caps your spending. |
| `requestDelayMs` | no | Delay between requests to the same site (default 300). |
| `headers` | no | Extra HTTP headers (for example `Accept-Language`). |
| `proxyConfiguration` | no | Only needed if the site blocks direct requests (403/429). |

#### Input example

List page with pagination and detail pages:

```json
{
  "startUrls": [{ "url": "https://books.toscrape.com/catalogue/category/books/travel_2/index.html" }],
  "itemSelector": "article.product_pod",
  "fields": [
    { "name": "title", "selector": "h3 a", "extract": "attr", "attribute": "title" },
    { "name": "price", "selector": ".price_color", "regex": "([0-9.]+)", "type": "number" },
    { "name": "url", "selector": "h3 a", "extract": "attr", "attribute": "href", "type": "url" }
  ],
  "nextPageSelector": "li.next a",
  "maxPages": 3,
  "detailLinkSelector": "h3 a",
  "detailFields": [
    { "name": "upc", "selector": "//th[text()='UPC']/following-sibling::td", "selectorType": "xpath" },
    { "name": "availability", "selector": "p.availability", "regex": "(\\d+) available", "type": "integer" },
    { "name": "description", "selector": "#product_description ~ p" }
  ],
  "maxResults": 45
}
```

### Output

#### Output example

Each row contains your own field names (list fields and detail fields), plus the metadata fields `pageUrl`, `pageNumber`, `itemIndex`, `missingFields` and `scrapedAt` (and `detailUrl` when detail pages are used). Short sample from the books.toscrape.com test site (values shortened):

```json
{
  "title": "It's Only the Himalayas",
  "price": 45.17,
  "url": "https://books.toscrape.com/catalogue/its-only-the-himalayas_981/index.html",
  "upc": "<upc>",
  "availability": 19,
  "description": "<description text>",
  "detailUrl": "https://books.toscrape.com/catalogue/its-only-the-himalayas_981/index.html",
  "pageUrl": "https://books.toscrape.com/catalogue/category/books/travel_2/index.html",
  "pageNumber": 1,
  "itemIndex": 0,
  "missingFields": [],
  "scrapedAt": "2026-10-04T18:12:36.799Z"
}
```

#### Output fields & fill rates

Measured on a 44-row test run (two category pages, pagination + detail pages) on books.toscrape.com. Fill rates depend on your selectors and on the target site.

| Field | Fill rate |
|---|---|
| title, price, url | 100% |
| upc, availability, description (detail page) | 100% |
| detailUrl | 100% |
| pageUrl, pageNumber, itemIndex, scrapedAt | 100% |
| missingFields (rows with at least one missing field) | 0% |

Other proof runs:

- **URL pattern pagination** (quotes.toscrape.com, `all: true`): 35 rows; `tags` was filled on 97.1% of rows (a quote without tags yields an empty list and is flagged in `missingFields`).
- **Single page, no `itemSelector`**: 2 start URLs gave 2 rows; a selector that matches nothing returns `null` and is listed in `missingFields`.
- **Selector that matches nothing**: the run succeeds with 0 rows and writes a `SELECTOR_REPORT` record with hints.
- **Empty input**: rejected with an "input is not valid" error (`startUrls` is required).

### Configuration

- **Selectors**: CSS by default; a selector starting with `/` (or `selectorType: "xpath"`) is XPath. Selectors in `fields` run inside each item; selectors in `detailFields` run on the whole detail page.
- **Pagination**: use either `nextPageSelector` or `pageUrlPattern` (with `{page}`), bounded by `maxPages`.
- **Cost control**: `maxResults` (default 100) stops the run after that many rows.
- **Politeness / blocking**: `requestDelayMs` (default 300 ms); enable `proxyConfiguration` only if the site answers 403/429.
- **Headers**: `headers` for things like `Accept-Language`; `Cookie` and `Authorization` are refused.

### How to use via API

Replace `YOUR_API_TOKEN` and `ACTOR_ID` (find it on the Actor page).

#### curl

```bash
curl -X POST "https://api.apify.com/v2/acts/ACTOR_ID/run-sync-get-dataset-items?token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "startUrls": [{"url": "https://quotes.toscrape.com/"}],
    "itemSelector": "div.quote",
    "fields": [
      {"name": "text", "selector": "span.text"},
      {"name": "author", "selector": "small.author"},
      {"name": "tags", "selector": "a.tag", "all": true}
    ],
    "pageUrlPattern": "https://quotes.toscrape.com/page/{page}/",
    "maxPages": 4,
    "maxResults": 35
  }'
```

#### JavaScript

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_API_TOKEN' });
const run = await client.actor('ACTOR_ID').call({
    startUrls: [{ url: 'https://quotes.toscrape.com/' }],
    itemSelector: 'div.quote',
    fields: [
        { name: 'text', selector: 'span.text' },
        { name: 'author', selector: 'small.author' },
        { name: 'tags', selector: 'a.tag', all: true },
    ],
    pageUrlPattern: 'https://quotes.toscrape.com/page/{page}/',
    maxPages: 4,
    maxResults: 35,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.length);
```

#### Python

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_API_TOKEN")
run = client.actor("ACTOR_ID").call(run_input={
    "startUrls": [{"url": "https://quotes.toscrape.com/"}],
    "itemSelector": "div.quote",
    "fields": [
        {"name": "text", "selector": "span.text"},
        {"name": "author", "selector": "small.author"},
        {"name": "tags", "selector": "a.tag", "all": True},
    ],
    "pageUrlPattern": "https://quotes.toscrape.com/page/{page}/",
    "maxPages": 4,
    "maxResults": 35,
})
items = client.dataset(run["defaultDatasetId"]).list_items().items
print(len(items))
```

### Pricing

Pay per result (pay-per-event): you are charged for each row written to the dataset. Price per 1,000 results depends on your Apify plan:

| Plan | Per 1,000 results |
|---|---|
| Free | $1.50 |
| Bronze | $1.30 |
| Silver | $1.15 |
| Gold and above | $1.00 |

Platform usage (compute) is billed by Apify separately; in the test runs it was small (the 44-row run used about $0.017 of platform usage). Set `maxResults` to cap your spending.

### Troubleshooting

- **0 results**: open the `SELECTOR_REPORT` record in the run's key-value store. Check that `itemSelector` and the field selectors match the HTML the server sends (view-source, not the browser inspector).
- **Fields are `null`**: the selector matched nothing inside the item; see `missingFields`. Remember selectors are evaluated inside each item.
- **Page needs JavaScript**: not supported; this Actor reads server-rendered HTML only.
- **HTTP 403/429**: enable Apify Proxy in `proxyConfiguration` and raise `requestDelayMs`.
- **Input error**: a field needs `name` and `selector`; `extract: "attr"` needs `attribute`; `detailFields` and `detailLinkSelector` go together; field names must be unique and not reserved.

### FAQ

#### Do I need to code?

No. You write selectors in JSON; no page function.

#### Can I use XPath?

Yes: a selector starting with `/` is treated as XPath, or set `selectorType: "xpath"`.

#### Can I scrape pages behind a login?

No. Public pages only; `Cookie` and `Authorization` headers are refused.

#### Is scraping legal?

Scrape only public data you are allowed to use, respect the site's terms and robots.txt, and handle any personal data in line with GDPR.

### Keywords

no code web scraper, css selector scraper, web scraper css selector, xpath scraper, html to json, website to json, extract data from website, pagination scraper, scrape product listings, structured data extraction, no-code data extraction

### Hashtags

\#webscraping #nocode #cssselector #xpath #htmltojson #dataextraction #scraper #automation #apify

# Changelog

This Actor's version history is a separate document: https://apify.com/leadsbrary/selector-map-web-scraper/changelog.md

# Actor input Schema

## `startUrls` (type: `array`):

Public pages to scrape (list pages, or single pages when no item selector is set).

## `itemSelector` (type: `string`):

CSS selector of each repeated item on a list page (e.g. article.product_pod). Leave empty to treat each page as ONE item.

## `fields` (type: `array`):

List of {name, selector, extract (text|html|attr), attribute, regex, type (string|number|integer|boolean|url), all, selectorType (auto|css|xpath)}. Selectors are evaluated inside each item. Selectors starting with / are XPath.

## `nextPageSelector` (type: `string`):

CSS selector of the 'next page' link (e.g. li.next a).

## `pageUrlPattern` (type: `string`):

Alternative to the next-page selector: URL containing {page}, e.g. https://site.com/list?page={page}. Used from page 2; stops at the first empty page.

## `maxPages` (type: `integer`):

Pagination limit for each start URL.

## `detailLinkSelector` (type: `string`):

Optional: link inside each item to follow to a detail page (e.g. h3 a). Requires detail fields.

## `detailFields` (type: `array`):

Fields read on the detail page (same format as Fields; evaluated on the whole page). Names must differ from list fields.

## `maxResults` (type: `integer`):

Stop after this many rows (also caps your spending).

## `requestDelayMs` (type: `integer`):

Politeness delay.

## `headers` (type: `object`):

Optional extra headers (e.g. Accept-Language). Cookie and Authorization are refused: public pages only.

## `proxyConfiguration` (type: `object`):

Only needed if the site blocks direct requests (HTTP 403/429).

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://books.toscrape.com/catalogue/category/books/travel_2/index.html"
    }
  ],
  "itemSelector": "article.product_pod",
  "fields": [
    {
      "name": "title",
      "selector": "h3 a",
      "extract": "attr",
      "attribute": "title"
    },
    {
      "name": "price",
      "selector": ".price_color",
      "regex": "([0-9.]+)",
      "type": "number"
    },
    {
      "name": "url",
      "selector": "h3 a",
      "extract": "attr",
      "attribute": "href",
      "type": "url"
    },
    {
      "name": "rating",
      "selector": "p.star-rating",
      "extract": "attr",
      "attribute": "class",
      "regex": "star-rating (\\w+)"
    }
  ],
  "maxPages": 1,
  "maxResults": 10,
  "requestDelayMs": 300,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrls": [
        {
            "url": "https://books.toscrape.com/catalogue/category/books/travel_2/index.html"
        }
    ],
    "itemSelector": "article.product_pod",
    "fields": [
        {
            "name": "title",
            "selector": "h3 a",
            "extract": "attr",
            "attribute": "title"
        },
        {
            "name": "price",
            "selector": ".price_color",
            "regex": "([0-9.]+)",
            "type": "number"
        },
        {
            "name": "url",
            "selector": "h3 a",
            "extract": "attr",
            "attribute": "href",
            "type": "url"
        },
        {
            "name": "rating",
            "selector": "p.star-rating",
            "extract": "attr",
            "attribute": "class",
            "regex": "star-rating (\\w+)"
        }
    ],
    "maxPages": 1,
    "maxResults": 10,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("leadsbrary/selector-map-web-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "startUrls": [{ "url": "https://books.toscrape.com/catalogue/category/books/travel_2/index.html" }],
    "itemSelector": "article.product_pod",
    "fields": [
        {
            "name": "title",
            "selector": "h3 a",
            "extract": "attr",
            "attribute": "title",
        },
        {
            "name": "price",
            "selector": ".price_color",
            "regex": "([0-9.]+)",
            "type": "number",
        },
        {
            "name": "url",
            "selector": "h3 a",
            "extract": "attr",
            "attribute": "href",
            "type": "url",
        },
        {
            "name": "rating",
            "selector": "p.star-rating",
            "extract": "attr",
            "attribute": "class",
            "regex": "star-rating (\\w+)",
        },
    ],
    "maxPages": 1,
    "maxResults": 10,
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("leadsbrary/selector-map-web-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrls": [
    {
      "url": "https://books.toscrape.com/catalogue/category/books/travel_2/index.html"
    }
  ],
  "itemSelector": "article.product_pod",
  "fields": [
    {
      "name": "title",
      "selector": "h3 a",
      "extract": "attr",
      "attribute": "title"
    },
    {
      "name": "price",
      "selector": ".price_color",
      "regex": "([0-9.]+)",
      "type": "number"
    },
    {
      "name": "url",
      "selector": "h3 a",
      "extract": "attr",
      "attribute": "href",
      "type": "url"
    },
    {
      "name": "rating",
      "selector": "p.star-rating",
      "extract": "attr",
      "attribute": "class",
      "regex": "star-rating (\\\\w+)"
    }
  ],
  "maxPages": 1,
  "maxResults": 10,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call leadsbrary/selector-map-web-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,leadsbrary/selector-map-web-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/WhR9iEzf6PblSa8AF/builds/Kb3bBZAm1X694nleg/openapi.json
