AI训练数据收集器(兼容MCP)
从网站中提取干净、LLM就绪的内容,用于人工智能培训、RAG管道和矢量数据库。具有自动分类、智能内容提取、令牌计数以及通过模型上下文协议与Claude/GPT无缝集成的功能。
🌟 特性
智能内容提取
- 智能内容检测 -自动识别主要内容,删除导航/广告
- 多站点爬行 -使用可配置的深度跟踪跨域的链接
- 主题过滤 -只收集与您的关键字匹配的内容
- 最低质量阈值 -自动跳过精简内容
AI就绪输出格式
- Markdown文件 -个人
.md每页文件+组合训练文件 - JSON数据集 -具有元数据和令牌计数的结构化数据
- 纯文本 -简单文本提取
- 下载就绪 -键值存储中可用的所有文件
自动分类
- NLP驱动的标签 -自动提取主题和关键字
- 元数据抽取 -标题、作者、出版日期、描述
- 代币计数 -使用tiktoken(GPT-4标记器)进行精确的成本计算
矢量数据库集成
- 嵌入就绪格式 -为ChromaDB、Pinecone、Weaviate预格式化
- 唯一ID -自动生成的文档标识符
- 元数据保存 -源URL、标签、标题
MCP兼容性
- 克劳德整合 -在Claude Desktop中用作工具
- GPT集成 -与GPT代理框架兼容
- 实时数据访问 -AI代理可以自主收集新的训练数据
🚀 用例
1.RAG管道数据收集
构建用于检索增强生成的知识库:
Input: Company documentation sites, technical blogs
Output: Clean markdown chunks with metadata
Use: Feed into LangChain, LlamaIndex, or custom RAG systems2.LLM微调数据集
收集特定领域的培训数据:
Input: Industry-specific websites, research papers, forums
Output: High-quality text with auto-tagging
Use: Fine-tune GPT, Claude, or open-source models3.AI Agent知识库
AI代理的实时数据:
Input: News sites, product pages, documentation
Output: MCP-compatible format
Use: Claude/GPT agents access fresh data on demand4.研究与分析
自动内容聚合:
Input: Multiple sources on a topic
Output: Categorized, tagged content
Use: Market research, competitive intelligence, trend analysis📋 输入配置
必填字段
开始URL
- 开始爬网的URL
- 例子:
["https://blog.example.com", "https://docs.example.com"]
可选配置
| 参数 | 默认值 | 说明 |
|---|---|---|
crawlStrategy | 相同域 | 如何跟踪链接(相同域、相同主机名、全部) |
maxCrawlDepth | 3 | 起始URL的最大链接深度 |
maxPagesPerDomain | 100 | 每个域的页面限制(控制成本) |
topicKeywords | \[\] | 按主题筛选(空=全部收集) |
contentSelectors | auto | 主要内容的CSS选择器 |
excludeSelectors | 导航、页脚等 | 要删除的元素 |
outputFormat | markdown | 输出格式(markdown/纯文本/json) |
includeMetadata | true | 包括标题、作者、日期、标签 |
autoTagging | true | 基于NLP的关键字提取 |
minContentLength | 100字 | 最低质量阈值 |
tokenLimit | 无限制 | N个代币后停止(成本控制) |
embeddings | false | 生成嵌入就绪格式 |
mcpCompatible | true | 模型上下文协议格式 |
🎯 输入示例
基本文件报废
{
"startUrls": ["https://docs.python.org/3/"],
"maxPagesPerDomain": 200,
"topicKeywords": ["python", "programming", "tutorial"],
"outputFormat": "markdown"
}人工智能训练数据收集
{
"startUrls": [
"https://machinelearningmastery.com",
"https://towardsdatascience.com"
],
"topicKeywords": ["machine learning", "deep learning", "neural networks"],
"maxPagesPerDomain": 500,
"autoTagging": true,
"embeddings": true,
"minContentLength": 300
}RAG客户支持管道
{
"startUrls": ["https://support.yourcompany.com"],
"crawlStrategy": "same-domain",
"outputFormat": "markdown",
"embeddings": true,
"mcpCompatible": true,
"contentSelectors": [".article-content", ".help-content"]
}成本可控的爬行
{
"startUrls": ["https://example.com"],
"maxPagesPerDomain": 50,
"tokenLimit": 100000,
"minContentLength": 200
}📊 输出格式
标准输出
{
"url": "https://example.com/article",
"title": "Understanding Machine Learning",
"content": "# Understanding Machine Learning\n\nMachine learning is...",
"wordCount": 1543,
"tokenCount": 2104,
"metadata": {
"description": "A comprehensive guide to ML",
"author": "John Doe",
"publishDate": "2024-01-15",
"tags": ["machine learning", "ai", "data science"],
"crawledAt": "2025-01-15T10:30:00.000Z"
}
}嵌入就绪格式
{
"embeddingReady": {
"id": "aHR0cHM6Ly9leGFtcGxlLmNvbQ",
"text": "Understanding Machine Learning\n\nMachine learning is...",
"metadata": {
"source": "https://example.com/article",
"title": "Understanding Machine Learning",
"tags": ["machine learning", "ai"]
}
}
}MCP格式
{
"mcp": {
"type": "document",
"source": "https://example.com/article",
"title": "Understanding Machine Learning",
"content": "# Understanding Machine Learning...",
"tokens": 2104
}
}📥 Markdown文件下载
除了JSON数据集,actor还会自动生成可下载的Markdown文件:
单个页面文件
每个收集的页面都另存为单独的 .md 文件在 键值存储:
- 命名:
page-0001.md,page-0002.md等等。 - 格式: 使用元数据标题清除标记
- 使用案例: 樱桃挑选特定页面进行培训
示例文件结构:
# Understanding Machine Learning
**Source:** https://example.com/article
**Collected:** 2025-01-15T10:30:00.000Z
---
# Understanding Machine Learning
Machine learning is a subset of artificial intelligence...综合培训文件
所有收集的内容合并为一个 TRAINING_DATA.md 文件:
- 地点: 键值存储→
TRAINING_DATA.md - 格式: 所有页面都用清晰的分隔符连接
- 使用案例: 大规模LLM训练、RAG摄取、微调数据集
组合文件示例:
# AI Training Data Collection
**Collection Date:** 2025-01-15T10:30:00.000Z
**Total Pages:** 26
**Total Tokens:** 93,986
**Total Words:** 62,421
---
# Understanding Machine Learning
**Source:** https://example.com/article
**Words:** 1,543 | **Tokens:** 2,104
---
Machine learning is a subset of artificial intelligence...
================================================================================
# Deep Learning Basics
...如何下载
- 运行完成后 → Go to 存储 标签
- 点击“键值存储”
- 下载选项:
- 单个文件:单击任何 page-XXXX.md - 组合文件:单击 TRAINING_DATA.md - 所有文件:使用“下载全部”按钮
💰 定价模型
按代币付费定价: 每10000个代币0.70美元
成本示例
- 小型文档站点 (50页,50万代币):3.50美元
- 媒体博客 (200页,200万代币):14.00美元
- 庞大的知识库 (1000页,1000万代币):70.00美元
成本控制功能
- 集
tokenLimit限制支出 - 使用
minContentLength跳过精简内容 - 过滤器
topicKeywords仅收集相关页面 - 监控日志中的实时令牌计数
🔧 MCP集成
Claude桌面设置
- 安装MCP服务器
npm install -g @apify/mcp-server-apify- 添加到Claude Config (
~/Library/Application Support/Claude/config.json):
{
"mcpServers": {
"ai-data-collector": {
"command": "npx",
"args": ["-y", "@apify/mcp-server-apify", "ai-training-data-collector"],
"env": {
"APIFY_API_TOKEN": "your_apify_token_here"
}
}
}
}- 重新启动克劳德
- 在Claude中使用
"Collect training data about React.js from reactjs.org documentation"Claude将自动调用此参与者并检索数据!
🛠️ 高级功能
自定义内容选择器
对于具有特定结构的场地:
{
"contentSelectors": [
"article.post-content",
".documentation-body",
"#main-content"
],
"excludeSelectors": [
".comments-section",
".related-posts",
".advertisement"
]
}多域爬行
{
"startUrls": [
"https://blog.company.com",
"https://docs.company.com",
"https://support.company.com"
],
"crawlStrategy": "all",
"maxPagesPerDomain": 200
}主题精选集
{
"startUrls": ["https://news.ycombinator.com"],
"topicKeywords": [
"artificial intelligence",
"machine learning",
"llm",
"gpt",
"claude"
],
"maxPagesPerDomain": 1000
}📈 演出
- 爬行速度: 每秒约10页
- 内容物清理: 自动移除样板
- 令牌精度: 使用官方tiktoken编码器
- 内存效率: 将数据流式传输到数据集
🔒 最佳实践
1.尊重robots.txt
爬虫自动尊重 robots.txt 指令。
2.设定合理的限制
{
"maxPagesPerDomain": 500,
"maxCrawlDepth": 3,
"tokenLimit": 1000000
}3.使用主题过滤
通过只收集相关内容来降低成本:
{
"topicKeywords": ["your", "specific", "topics"]
}4.监控令牌使用情况
检查日志以了解实时令牌计数和成本估算。
🐛 故障排除
未提取内容
- 检查
contentSelectors-可能需要特定于站点的选择器 - 验证站点是否允许爬行(检查robots.txt)
- 尝试不同
crawlStrategy
跳过的页面太多
- 降低
minContentLength阈值 - 拓宽
topicKeywords或删除过滤 - 检查
excludeSelectors未删除主要内容
高成本
- 集
tokenLimit限制支出 - 减少
maxPagesPerDomain - 使用
topicKeywords用于有针对性的收集 - 增加
minContentLength跳过薄页
📚 与流行框架一起使用
LangChain集成
from langchain.document_loaders import ApifyDatasetLoader
loader = ApifyDatasetLoader(
dataset_id="your_dataset_id",
dataset_mapping_function=lambda item: Document(
page_content=item["content"],
metadata=item["metadata"]
)
)
docs = loader.load()LlamaIdex集成
from llama_index import download_loader
ApifyLoader = download_loader("ApifyDataset")
loader = ApifyLoader("your_dataset_id")
documents = loader.load_data()ChromaDB集成
import chromadb
# Load dataset from Apify
dataset = apify_client.dataset("your_dataset_id").list_items().items
# Add to ChromaDB
for item in dataset:
if "embeddingReady" in item:
collection.add(
documents=[item["embeddingReady"]["text"]],
metadatas=[item["embeddingReady"]["metadata"]],
ids=[item["embeddingReady"]["id"]]
)🎓 示例和教程
马上就来:
- 使用收集的数据构建RAG聊天机器人
- 在自定义数据集上微调GPT
- 创建特定领域的知识库
- MCP集成模式
📄 许可证
阿帕奇-2.0
______________________________________________________________________
收集高质量的培训数据。构建更好的人工智能系统。
