# AI Web Scraper: Extract Structured Data from Any Website (`dailypalslab/ai-web-extractor`) Actor

AI web scraper that turns any web page into clean JSON. Describe the fields in plain English ("product name, price, in stock") or paste a JSON schema; an LLM (Claude or GPT, your own API key) extracts them from each page. Works on product lists, job posts, articles and business pages.

- **URL**: https://apify.com/dailypalslab/ai-web-extractor.md
- **Developed by:** [DailyPals Lab](https://apify.com/dailypalslab) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## AI Web Scraper: Extract Structured Data from Any Website to JSON

**Turn any web page into clean, structured JSON with AI.** Paste page URLs, say what you want in plain English ("product name, price, currency, in stock, rating") or paste a JSON schema, and an LLM (Anthropic **Claude** or OpenAI **GPT**, with your own API key) reads each page and returns exactly those fields. No CSS selectors, no XPath, no scraper code to maintain when the site changes.

- 🧠 **LLM data extraction**: describe fields in plain English or give an exact JSON schema
- 📋 **Lists or single records**: "all products on this page" returns an array; a product page returns one object
- 🧹 **Clean input for the model**: pages are converted to compact Markdown (menus, footers, cookie banners, scripts and ads removed) and cut to your token budget, so you pay your LLM for content, not boilerplate
- 🚫 **No made-up values**: missing fields come back as `null`, types are checked (numbers are numbers, booleans are booleans)
- 🔗 **Optional same-site crawl**: follow links from your pages (respects robots.txt and its crawl delay)
- 🔑 **Bring your own key**: Claude (default `claude-haiku-5-5`) or GPT (default `gpt-5.4-mini`), any model your key can use
- 🆓 **Free Demo mode**: no key needed to try it. You get the cleaned Markdown of each page plus a suggested schema, and nothing is charged

### What can you use this AI web scraper for?

- **E-commerce and price monitoring**: product name, price, currency, availability, rating and URL from category pages or product pages of any shop.
- **Job posts**: title, company, location, salary range, remote flag and apply link from careers pages and job boards.
- **Business directories and company pages**: company name, address, opening hours, main phone, website, services. *Business information only*: see [Responsible use](#responsible-use).
- **Real estate, events, recipes, reviews**: price, size, date, venue, ingredients, average rating... any field you can name.
- **News and articles**: headline, publish date, summary, topics.
- **AI agents and RAG**: website to JSON or website to Markdown in one step, through the Apify API or MCP server.

### How to use it

1. Add one or more **page URLs**.
2. Describe **what to extract**, e.g. `For every product: name, price, currency, in stock, rating, product URL`. Words like *every*, *all* or *each* switch on list mode. Or paste a **JSON schema** for exact field names and types.
3. Choose your **AI provider** and paste your **API key** (from [console.anthropic.com](https://console.anthropic.com) or [platform.openai.com](https://platform.openai.com)). Leave the model empty for the low-cost default.
4. Click **Start**. Download the results as JSON, CSV or Excel, or get them via API, webhook, Zapier, Make or Google Sheets.

When you use a plain-English description, the Actor first makes **one small LLM call** to turn it into a JSON schema. That schema is saved in the run's **SUMMARY** record (`jsonSchema`), so you can copy it into the **JSON schema** field next time for stable field names across runs.

#### Demo mode (no API key)

With provider **Auto** and no key (the default), or provider **Demo**, the Actor does everything except the AI call: it fetches each page, returns the **cleaned Markdown** that the model would receive (`markdown` field) and puts a **suggested schema** built from your description in SUMMARY. Demo runs are **free** (no events charged). Use it to check that a site can be read before you spend tokens.

### Input example

```json
{
  "urls": ["https://books.toscrape.com/"],
  "extractionPrompt": "For every book on the page: title, price, currency, in stock, star rating, product URL",
  "provider": "anthropic",
  "apiKey": "sk-ant-...",
  "listMode": "auto",
  "maxCharsPerPage": 40000
}
```

With an exact schema instead (shorthand `{"field": "type"}` works too):

```json
{
  "urls": ["https://example.com/careers/senior-data-engineer"],
  "jsonSchema": {
    "type": "object",
    "properties": {
      "jobTitle": { "type": "string" },
      "location": { "type": "string" },
      "remote": { "type": "boolean" },
      "salaryMin": { "type": "number" },
      "salaryMax": { "type": "number" },
      "salaryCurrency": { "type": "string" },
      "applyUrl": { "type": "string" }
    }
  },
  "provider": "openai",
  "apiKey": "sk-..."
}
```

For list pages, use an array schema (`{"type": "array", "items": {...}}`) or set **Records per page** to *List*.

### Output example

One row per page:

```json
{
  "url": "https://books.toscrape.com/",
  "title": "All products | Books to Scrape - Sandbox",
  "data": [
    { "title": "A Light in the Attic", "price": 51.77, "currency": "GBP", "inStock": true, "starRating": 3, "productUrl": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html" },
    { "title": "Tipping the Velvet", "price": 53.74, "currency": "GBP", "inStock": true, "starRating": 1, "productUrl": "https://books.toscrape.com/catalogue/tipping-the-velvet_999/index.html" }
  ],
  "itemCount": 20,
  "fieldsFound": 6,
  "provider": "anthropic",
  "model": "claude-haiku-5-5",
  "inputTokens": 2650,
  "outputTokens": 1900,
  "markdownChars": 8355,
  "truncated": false,
  "warnings": [],
  "error": null,
  "extractedAt": "2026-11-22T12:00:00.000Z"
}
```

- `data`: an object (one record per page) or an array (list mode). Fields not found on the page are `null`.
- `fieldsFound`: how many schema fields have a value (list mode: fields found in at least one item).
- `inputTokens` / `outputTokens`: what your LLM provider bills you for this page.
- `warnings`: values the model returned that did not match the type (they are set to `null` rather than guessed).
- `error`: why a page failed (HTTP error, no readable text, model error). Failed pages are **not charged**.
- Turn on **Include page Markdown** to also get the cleaned `markdown` that was sent to the model.

The **SUMMARY** record has the schema used (`jsonSchema`), total tokens, pages OK/failed, pages skipped by robots.txt, and whether the cost limit stopped the run.

### Pricing

Pay per event, no monthly fee:

| Event | Price |
| --- | --- |
| `page`: each page fetched and extracted successfully | **$0.002** |

That is **$2 per 1,000 pages**, plus your own LLM provider's token cost (billed by Anthropic or OpenAI to your key). Demo runs and failed pages are free. Set **Max cost per run** in the run options and the Actor stops cleanly before going over it; **Max pages** caps a run too.

**Typical LLM cost per page** with the defaults: a product list page of ~8,000 characters is about 2,500 input tokens; a long article capped at 40,000 characters is about 10,000. With small models (Claude Haiku, GPT mini) that is usually a fraction of a cent per page. Lower **Max characters per page** to spend less on long pages.

### FAQ

**Do I need my own API key?**
Yes, for AI extraction: an Anthropic or OpenAI key. Without one, the Actor runs in free Demo mode (cleaned Markdown + suggested schema, no AI).

**Is my API key safe?**
The key field is a secret input: Apify stores it encrypted and hides it in the run's input. The Actor uses it only to call your provider during that run, never logs it, and never writes it to the results or the SUMMARY. You can create a dedicated key with a spending limit in your provider's console and revoke it at any time.

**What will my LLM provider charge?**
Their normal per-token price for the model you choose. Each row shows `inputTokens` and `outputTokens`, and SUMMARY shows the run total (including the one small schema-generation call when you use a plain-English description).

**Which model should I use?**
The defaults (`claude-haiku-5-5`, `gpt-5.4-mini`) are fast and cheap and handle most pages. For very long or messy pages, or many items per page, try a larger model such as `claude-sonnet-5-5` or `gpt-5.5` in the **Model** field.

**Does the AI make up data?**
It is instructed to use only what is on the page and to return `null` for anything missing, and every value is type-checked afterwards. Always spot-check results for important uses.

**Does it work on JavaScript-heavy sites?**
This version reads the HTML the server sends (fast and cheap). Pages that build their content only in the browser come back with an error such as "Page has no readable text". Use Demo mode to check a site first.

**How do I crawl a whole site?**
Turn on **Follow links on the same website** and set **Max pages**. Links in the main content are followed first, robots.txt rules and crawl delays are respected, and login, cart and file links are skipped.

**Can I call it from code or an AI agent?**
Yes: the Apify API, JavaScript/Python clients, the CLI, the Apify MCP server, or Make/Zapier/n8n integrations.

### Responsible use

Use this tool for **public, non-personal information**: products, prices, jobs, articles, and **business** details such as a company's name, address, opening hours and main contact channels. **Don't use it to collect personal data** about individuals (private emails, phone numbers, profiles), don't bypass logins or paywalls, and follow each website's terms and applicable laws such as the GDPR and CCPA. The Actor only visits the URLs you give it (and, if you enable crawling, same-site links allowed by robots.txt).

### Support

Found a page that doesn't extract well, or need a feature (JavaScript rendering, more providers)? Open an issue on the **Issues** tab with the URL and your input. Made by **Daily Pals Labs**.

# Actor input Schema

## `urls` (type: `array`):

Web pages to extract data from, one per line (product lists, product pages, job posts, articles, company pages...). Pages must load without a login. JavaScript-only pages are not rendered in this version.

## `extractionPrompt` (type: `string`):

Describe the fields you want, e.g. "For every product: name, price, currency, in stock, rating, product URL" or "company name, phone, opening hours, address". If you don't give a JSON schema, one is built from this description (shown in the run's SUMMARY so you can reuse it). Use words like "every" or "all" to get a list of items per page.

## `jsonSchema` (type: `object`):

Exact fields to return, as a JSON schema ({"type":"object","properties":{"price":{"type":"number"}}}), an array schema for lists, or a shorthand like {"name":"string","price":"number","tags":\["string"]}. Overrides the schema built from the description; the description is still passed to the model as extra instructions.

## `listMode` (type: `string`):

Single: one record per page (a product page, a job post). List: every matching item on the page (all products in a category, all jobs on a careers page). Auto: decided from your schema or description.

## `crawlSameSite` (type: `boolean`):

Also extract from pages linked from your URLs on the same website (breadth-first, respects robots.txt and its crawl delay), up to the maximum number of pages.

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

Maximum number of pages to process in this run, including your URLs (1-500). Each successful page is one charged event.

## `maxCharsPerPage` (type: `integer`):

Page Markdown is cut to this many characters before it is sent to the model (about 4 characters per token, so 40,000 ≈ 10,000 input tokens). Lower it to save on your LLM bill; raise it for very long pages.

## `provider` (type: `string`):

Which LLM extracts the data, using your own API key. Auto: detected from the key (sk-ant-... = Anthropic, sk-... = OpenAI); with no key it runs the free Demo. Demo: no AI, returns the cleaned page Markdown and a suggested schema, nothing charged.

## `apiKey` (type: `string`):

Your Anthropic (console.anthropic.com) or OpenAI (platform.openai.com) API key. Leave empty to run the free Demo.

## `model` (type: `string`):

Model name. Leave empty for the fast, low-cost default: claude-haiku-5-5 (Anthropic) or gpt-5.4-mini (OpenAI). Any model your key can use works, e.g. claude-sonnet-5-5 or gpt-5.5 for harder pages.

## `maxConcurrency` (type: `integer`):

How many pages are fetched and sent to the model at the same time. Lower it if your provider rate-limits you; rate-limit errors are retried with backoff.

## `includeMarkdown` (type: `boolean`):

Add the cleaned Markdown that was sent to the model to each row (handy for checking results or for RAG). Always on in Demo mode.

## Actor input object example

```json
{
  "urls": [
    "https://books.toscrape.com/"
  ],
  "extractionPrompt": "For every book on the page: title, price, currency, in stock, star rating, product URL",
  "listMode": "auto",
  "crawlSameSite": false,
  "maxPages": 10,
  "maxCharsPerPage": 40000,
  "provider": "auto",
  "maxConcurrency": 3,
  "includeMarkdown": false
}
```

# Actor output Schema

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

One row per page with the extracted data (JSON, CSV, Excel via the API).

## `summary` (type: `string`):

The JSON schema used (reusable), token usage, counts and failures for this run.

# 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 = {
    "urls": [
        "https://books.toscrape.com/"
    ],
    "extractionPrompt": "For every book on the page: title, price, currency, in stock, star rating, product URL"
};

// Run the Actor and wait for it to finish
const run = await client.actor("dailypalslab/ai-web-extractor").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 = {
    "urls": ["https://books.toscrape.com/"],
    "extractionPrompt": "For every book on the page: title, price, currency, in stock, star rating, product URL",
}

# Run the Actor and wait for it to finish
run = client.actor("dailypalslab/ai-web-extractor").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 '{
  "urls": [
    "https://books.toscrape.com/"
  ],
  "extractionPrompt": "For every book on the page: title, price, currency, in stock, star rating, product URL"
}' |
apify call dailypalslab/ai-web-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,dailypalslab/ai-web-extractor"
        }
    }
}
```

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/hRbIq2thxvAobMOhb/builds/vKQaXFLRcgzacLhmx/openapi.json
