# Custom JavaScript Web Data Extractor with Cheerio

**Use case:** 

Run a custom JavaScript page function on static HTML and return structured JSON records using Cheerio without the cost of a headless browser.

## Input

```json
{
  "startUrls": [
    {
      "url": "https://books.toscrape.com/"
    }
  ],
  "extractionRules": [
    {
      "name": "pageTitle",
      "selector": "h1",
      "type": "text"
    },
    {
      "name": "products",
      "selector": ".product_pod h3 a",
      "type": "attribute",
      "attribute": "title",
      "multiple": true
    }
  ],
  "pageFunction": "async function pageFunction({ $, request }) { return $('.product_pod').map((_, el) => ({ sourceUrl: request.loadedUrl || request.url, title: $(el).find('h3 a').attr('title'), price: $(el).find('.price_color').text().trim() })).get(); }",
  "linkSelector": "a[href]",
  "globs": [
    {
      "glob": "https://books.toscrape.com/catalogue/**"
    }
  ],
  "excludes": [
    {
      "glob": "**/*.{jpg,jpeg,png,gif,svg,pdf,zip}"
    }
  ],
  "sameDomainOnly": true,
  "maxCrawlingDepth": 1,
  "maxPagesPerCrawl": 1,
  "maxResultsPerCrawl": 20,
  "includePageMetadata": true,
  "includeJsonLd": true,
  "removeEmptyFields": true,
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "additionalHeaders": {},
  "maxConcurrency": 20,
  "maxRequestRetries": 3,
  "requestTimeoutSecs": 45,
  "respectRobotsTxtFile": true,
  "customData": {},
  "debugLog": false
}
```

## Output

```json
{
  "url": {
    "label": "URL",
    "format": "link"
  },
  "statusCode": {
    "label": "Status"
  },
  "title": {
    "label": "Title"
  },
  "description": {
    "label": "Description"
  },
  "canonicalUrl": {
    "label": "Canonical",
    "format": "link"
  },
  "language": {
    "label": "Language"
  },
  "h1": {
    "label": "Headings",
    "format": "array"
  },
  "image": {
    "label": "Image",
    "format": "link"
  }
}
```

## About this Actor

This example demonstrates how to use [Cheerio Web Scraper - Fast HTTP Crawler & CSS Extractor](https://apify.com/groupoject/cheerio-web-scraper.md) with a specific input configuration. Visit the [Actor detail page](https://apify.com/groupoject/cheerio-web-scraper.md) to learn more, explore other use cases, and run it yourself.


## 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.
This Task's input is already configured above — use it as-is rather than inventing a new one.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For full API examples (JavaScript, Python, CLI, MCP, OpenAPI), see this Task's Actor page: https://apify.com/groupoject/cheerio-web-scraper.md

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).
