# AI Training Data Collector — Clean Web Datasets for LLMs (`avinashchby/ai-training-data-collector`) Actor

Crawl websites and extract structured, clean text datasets perfect for fine-tuning LLMs and RAG pipelines. Removes boilerplate, deduplicates, and scores content quality.

- **URL**: https://apify.com/avinashchby/ai-training-data-collector.md
- **Developed by:** [Avinash](https://apify.com/avinashchby) (community)
- **Categories:** AI, Marketing
- **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.
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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **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 usage examples, see the [API](#api) section below.

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).

# README

## AI Training Data Collector — Structured Web Datasets for LLMs

Crawl websites and extract structured, clean text datasets perfect for fine-tuning LLMs and RAG pipelines. This AI training data collector removes boilerplate, deduplicates content, and scores quality for AI training.

### How It Works

The actor launches a Cheerio crawler from your start URLs and follows internal links up to the configured crawl depth, skipping any URL that matches an exclude pattern. For each page it strips nav, header, footer, sidebar, ads, and script elements, then isolates the main content region and converts the remaining HTML into markdown, plain text, or a structured JSON object. It counts words, headings, paragraphs, links, and images, computes a 0-100 quality score from length, vocabulary diversity, sentence count, and structure, and deduplicates via an MD5 hash of the first 2,000 characters before pushing the record to the dataset.

### Features

- **Smart content extraction**: Removes navigation, ads, footers, and boilerplate
- **Multi-format output**: Markdown, plain text, or JSON-Lines
- **Quality scoring**: Each page scored 0-100 for training suitability
- **Deduplication**: Content hash-based deduplication across pages
- **Configurable depth**: 0-3 levels of crawl depth from start URLs
- **Pattern exclusion**: Skip unwanted URL patterns (tags, categories, etc.)

### Input Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `urls` | array | Wikipedia AI page | Start URLs to crawl |
| `crawlDepth` | integer | `1` | Link follow depth (0-3) |
| `maxPages` | integer | `5` | Max pages to process |
| `outputFormat` | string | `markdown` | Content format |
| `excludePatterns` | array | tags, categories | URL patterns to skip |
| `minWordCount` | integer | `100` | Skip short pages |
| `proxyConfiguration` | object | Apify Proxy | Proxy for reliable scraping |

### Output Example

```json
{
  "url": "https://en.wikipedia.org/wiki/Artificial_intelligence",
  "title": "Artificial intelligence - Wikipedia",
  "wordCount": 4128,
  "qualityScore": 87,
  "sourceDomain": "en.wikipedia.org",
  "contentType": "start",
  "language": "en",
  "crawlDepth": 0,
  "headingCount": 56,
  "paragraphCount": 142,
  "linkCount": 311,
  "images": 14,
  "contentHash": "a3f9c1e8b2d4",
  "extractionMethod": "cheerio-html2text",
  "scrapedAt": "2026-07-27T16:00:00.000Z",
  "cleanText": "# Artificial intelligence\n\nArtificial intelligence (AI) is the intelligence of machines..."
}
```

### Use Cases

- **LLM fine-tuning**: Build custom training datasets from any website
- **RAG pipelines**: Create knowledge base documents for retrieval-augmented generation
- **Research datasets**: Collect structured content for academic research
- **Competitive analysis**: Extract and analyze competitor website content

### Cost Estimate

- 5 pages: ~$0.25
- 100 pages: ~$2.00
- 1000 pages: ~$15.00

# Actor input Schema

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

List of URLs to crawl for training data

## `crawlDepth` (type: `integer`):

How many levels deep to crawl from start URLs (0 = only start URLs)

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

Maximum number of pages to process

## `outputFormat` (type: `string`):

Format for extracted content

## `excludePatterns` (type: `array`):

Regex patterns for URLs to skip (e.g., '/blog/tag/', '/admin/')

## `minWordCount` (type: `integer`):

Skip pages with fewer words than this threshold

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

Select a proxy to avoid blocking. Use Apify Proxy (recommended) or bring your own.

## Actor input object example

```json
{
  "urls": [
    {
      "url": "https://en.wikipedia.org/wiki/Artificial_intelligence"
    }
  ],
  "crawlDepth": 1,
  "maxPages": 5,
  "outputFormat": "markdown",
  "excludePatterns": [
    "/tag/",
    "/category/",
    "/author/",
    "/search/"
  ],
  "minWordCount": 100,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

All processed pages with clean text and quality scores.

# 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": [
        {
            "url": "https://en.wikipedia.org/wiki/Artificial_intelligence"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("avinashchby/ai-training-data-collector").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": [{ "url": "https://en.wikipedia.org/wiki/Artificial_intelligence" }] }

# Run the Actor and wait for it to finish
run = client.actor("avinashchby/ai-training-data-collector").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": [
    {
      "url": "https://en.wikipedia.org/wiki/Artificial_intelligence"
    }
  ]
}' |
apify call avinashchby/ai-training-data-collector --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,avinashchby/ai-training-data-collector"
        }
    }
}

```

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/foqxqk29GkowwoXod/builds/PukfWM6MeMgusBLj5/openapi.json
