CrawlForge
首页Playground应用场景集成价格文档博客
MCP web scraping 完全指南:开发者需要了解的一切
Web Scraping
返回博客
Web 抓取

MCP web scraping 完全指南:开发者需要了解的一切

C
CrawlForge Team
工程团队
2026年1月24日
阅读时长 20 分钟
更新于 2026年4月14日

本页内容

快速解答

MCP(Model Context Protocol)是 Anthropic 推出的开放标准,让 Claude 等 AI 助手能够通过 JSON-RPC 直接连接到外部工具。对于 web scraping,MCP 以原生的工具调用取代脆弱的 REST 集成 —— Claude 发现并调用 CrawlForge 的 26 个抓取工具的方式,与它使用内置能力时完全一样。

Model Context Protocol(MCP)从根本上改变了 AI 助手与网络交互的方式。这份全面的指南涵盖了开发者关于 MCP web scraping 需要了解的一切 —— 从基础概念到进阶技巧。

第一部分:理解 MCP

什么是 Model Context Protocol?

MCP(Model Context Protocol)是一个由 Anthropic 开发的开放标准,让 Claude 等 AI 助手能够连接到外部工具和数据源。可以把它看作一个通用适配器,让 AI 模型能够使用专用工具。

┌─────────────┐ ┌───────────────┐ ┌──────────────┐ │ Claude │ ←──→ │ MCP Server │ ←──→ │ External │ │ (AI Model) │ │ (CrawlForge) │ │ Resources │ └─────────────┘ └───────────────┘ └──────────────┘ ↑ MCP Protocol (JSON-RPC over stdio)

为什么 MCP 对 web scraping 至关重要

在 MCP 出现之前,AI 助手无法可靠地访问网页数据:

方法问题
训练数据过时,存在知识截止
RAG(检索)仅限于已索引的文档
函数调用需要自定义实现
浏览器插件不稳定,存在安全顾虑

MCP 通过以下方式解决了这些问题:

  • 标准化接口 —— 一套协议适配所有工具
  • 实时数据 —— 来自任意来源的最新信息
  • 工具可组合性 —— 无缝组合多个工具
  • 安全模型 —— 对外部资源的受控访问

MCP 的工作原理

MCP 采用基于 JSON-RPC 的客户端-服务器架构:

1. 服务器发现

Json
{
  "mcpServers": {
    "crawlforge": {
      "command": "npx",
      "args": ["crawlforge-mcp-server"]
    }
  }
}

2. 工具注册

Json
{
  "tools": [
    {
      "name": "fetch_url",
      "description": "Fetch content from a URL",
      "inputSchema": {
        "type": "object",
        "properties": {
          "url": { "type": "string", "format": "uri" }
        },
        "required": ["url"]
      }
    }
  ]
}

3. 工具调用

Json
{
  "method": "tools/call",
  "params": {
    "name": "fetch_url",
    "arguments": {
      "url": "https://example.com"
    }
  }
}

4. 响应

Json
{
  "result": {
    "content": "<html>...",
    "status": 200,
    "headers": {...}
  }
}

第二部分:MCP web scraping 生态

MCP 抓取服务器

有多个 MCP server 提供 web scraping 能力:

服务器工具数侧重点
CrawlForge20全面的抓取、研究、隐身
Firecrawl~5基础抓取与爬取
Browser MCP~3浏览器自动化
Fetch MCP1简单的 HTTP 请求

为什么 CrawlForge 领先

CrawlForge 专为 MCP 而构建,拥有最广泛的工具覆盖:

CrawlForge: ████████████████████ 26 tools Firecrawl: █████ 5 tools Browser: ███ 3 tools Fetch: █ 1 tool

第三部分:CrawlForge 的 26 个工具详解

基础抓取(1-2 credits)

1. fetch_url(1 credit)

web scraping 的基石 —— 从任意 URL 抓取原始 HTML。

Typescript
// Usage:
"Fetch https://example.com"

// Returns:
{
  "html": "<html>...",
  "status": 200,
  "headers": {...},
  "timing": { "total": 523 }
}

何时使用: 任何抓取任务的起点。永远先试它。

2. extract_text(1 credit)

提取干净的文本内容,移除 HTML 标签、脚本和样式。

Typescript
// Usage:
"Extract text from https://example.com/article"

// Returns:
{
  "text": "Article headline\n\nFirst paragraph...",
  "wordCount": 1247,
  "readingTime": 5
}

何时使用: 博客文章、报道、文档等需要可读文本的场景。

3. extract_links(1 credit)

发现页面上的所有链接,可选过滤。

Typescript
// Usage:
"Extract all links from https://example.com"

// With filtering:
{
  "url": "https://example.com",
  "filter_external": true  // Internal links only
}

// Returns:
{
  "links": [
    { "href": "/about", "text": "About Us" },
    { "href": "/products", "text": "Products" }
  ],
  "total": 45
}

何时使用: 站点探索、查找待抓取的页面、构建站点地图。

4. extract_metadata(1 credit)

提取 SEO 元数据:标题、描述、Open Graph、JSON-LD。

Typescript
// Usage:
"Get metadata from https://example.com"

// Returns:
{
  "title": "Example Site - Homepage",
  "description": "Welcome to Example...",
  "openGraph": {
    "title": "Example Site",
    "image": "https://example.com/og.png"
  },
  "jsonLd": [...]
}

何时使用: SEO 分析、内容预览、结构化数据提取。

结构化提取(2-3 credits)

5. scrape_structured(2 credits)

使用 CSS 选择器提取特定数据。

Typescript
// Usage:
{
  "url": "https://example.com/products",
  "selectors": {
    "title": "h1.product-title",
    "price": "span.price",
    "description": ".product-description"
  }
}

// Returns:
{
  "data": {
    "title": "Product Name",
    "price": "$99.99",
    "description": "Product description..."
  }
}

何时使用: 电商抓取、结构化数据、已知的页面布局。

6. extract_content(2 credits)

智能的文章提取(类似 Readability)。

Typescript
// Usage:
"Extract the main content from https://blog.example.com/post"

// Returns:
{
  "title": "Blog Post Title",
  "author": "John Smith",
  "publishedDate": "2026-01-15",
  "content": "Clean article text...",
  "images": ["..."],
  "readingTime": 7
}

何时使用: 新闻报道、博客文章、编辑类内容。

7. map_site(2 credits)

发现站点结构并生成站点地图。

Typescript
// Usage:
{
  "url": "https://example.com",
  "max_urls": 1000,
  "include_sitemap": true
}

// Returns:
{
  "pages": [
    { "url": "/", "title": "Home", "depth": 0 },
    { "url": "/about", "title": "About", "depth": 1 },
    ...
  ],
  "structure": {
    "/": ["/about", "/products", "/blog"],
    "/products": ["/products/1", "/products/2"]
  }
}

何时使用: 站点审计、爬取规划、内容发现。

8. analyze_content(3 credits)

NLP 分析:语言、情感、主题、实体。

Typescript
// Usage:
"Analyze this content: [text]"

// Returns:
{
  "language": "en",
  "sentiment": { "score": 0.7, "label": "positive" },
  "topics": ["technology", "AI", "automation"],
  "entities": [
    { "text": "OpenAI", "type": "organization" },
    { "text": "GPT-4", "type": "product" }
  ],
  "readability": { "grade": 12, "score": 45 }
}

何时使用: 内容分析、情感跟踪、主题提取。

进阶抓取(4-5 credits)

9. process_document(2 credits)

处理 PDF 和文档。

Typescript
// Usage:
{
  "source": "https://example.com/report.pdf",
  "sourceType": "pdf_url"
}

// Returns:
{
  "text": "Extracted PDF text...",
  "pages": 15,
  "metadata": {
    "author": "...",
    "created": "..."
  }
}

何时使用: 研究论文、报告、文档类 PDF。

10. summarize_content(4 credits)

AI 驱动的摘要生成。

Typescript
// Usage:
"Summarize this article: [long text]"

// Returns:
{
  "summary": "Concise summary...",
  "keyPoints": [
    "Point 1",
    "Point 2",
    "Point 3"
  ],
  "wordReduction": "85%"
}

何时使用: 长文档、研究综合、内容摘要。

11. crawl_deep(4 credits)

可配置深度的多页面爬取。

Typescript
// Usage:
{
  "url": "https://example.com",
  "max_depth": 3,
  "max_pages": 100,
  "include_patterns": ["/blog/*"],
  "exclude_patterns": ["/admin/*"]
}

// Returns:
{
  "pages": [...],  // All crawled pages
  "stats": {
    "total": 87,
    "successful": 85,
    "failed": 2
  }
}

何时使用: 全站抓取、内容聚合、归档。

12. batch_scrape(5 credits)

并行抓取多个 URL。

Typescript
// Usage:
{
  "urls": [
    "https://example1.com",
    "https://example2.com",
    // ... up to 50 URLs
  ],
  "maxConcurrency": 10
}

// Returns:
{
  "results": [
    { "url": "...", "success": true, "data": {...} },
    ...
  ],
  "stats": { "successful": 48, "failed": 2 }
}

何时使用: 多个已知 URL、竞品监控、价格跟踪。

13. scrape_with_actions(5 credits)

带操作的浏览器自动化。

Typescript
// Usage:
{
  "url": "https://example.com/app",
  "actions": [
    { "type": "wait", "selector": ".content" },
    { "type": "click", "selector": "#load-more" },
    { "type": "wait", "timeout": 2000 },
    { "type": "scroll", "selector": "body" },
    { "type": "screenshot" }
  ]
}

// Returns:
{
  "finalContent": "...",
  "screenshots": ["base64..."],
  "actionsExecuted": 5
}

何时使用: SPA、无限滚动、动态内容、需要登录的场景。

14. search_web(5 credits)

Google 搜索集成。

Typescript
// Usage:
{
  "query": "web scraping best practices 2026",
  "limit": 10,
  "site": "github.com"  // Optional site filter
}

// Returns:
{
  "results": [
    {
      "title": "...",
      "url": "...",
      "snippet": "..."
    },
    ...
  ]
}

何时使用: 发现、查找来源、研究的起点。

专用工具(3-10 credits)

15. stealth_mode(5 credits)

反检测绕过(详见隐身模式指南)。

Typescript
// Usage:
{
  "operation": "create_context",
  "stealthConfig": {
    "level": "advanced",
    "hideWebDriver": true,
    "randomizeFingerprint": true,
    "simulateHumanBehavior": true
  }
}

何时使用: 受保护的站点、绕过 Cloudflare、规避反爬虫。

16. track_changes(3 credits)

内容监控与变更检测。

Typescript
// Usage:
{
  "url": "https://example.com/pricing",
  "operation": "create_baseline",
  "monitoringOptions": {
    "interval": 86400000,  // Daily
    "notificationThreshold": "moderate"
  }
}

// Returns (on change):
{
  "changes": [
    {
      "type": "text_change",
      "path": ".pricing-tier-1",
      "before": "$19/mo",
      "after": "$29/mo",
      "significance": "major"
    }
  ]
}

何时使用: 价格监控、竞品跟踪、内容更新。

17. localization(2 credits)

地理定向抓取。

Typescript
// Usage:
{
  "operation": "configure_country",
  "countryCode": "GB",
  "language": "en-GB"
}

// Then scrape to get UK-specific content/pricing

何时使用: 区域定价、本地化内容、地理限制数据。

18. extract_structured(3 credits)

LLM 驱动、由 schema 引导的提取,并支持 CSS 选择器回退。

Typescript
// Usage:
{
  "url": "https://example.com/product/123",
  "schema": {
    "type": "object",
    "properties": {
      "title": { "type": "string" },
      "price": { "type": "number" }
    },
    "required": ["title"]
  },
  "prompt": "Extract the product name and price"
}

何时使用: 当你想要符合某个 schema 的类型化输出,又不想手写选择器时。

19. generate_llms_txt(5 credits)

分析一个站点并生成符合标准的 llms.txt 和 llms-full.txt 文件。

Typescript
// Usage:
{
  "url": "https://example.com",
  "format": "both",
  "complianceLevel": "standard",
  "outputOptions": {
    "organizationName": "Example Inc.",
    "contactEmail": "ai@example.com"
  }
}

何时使用: 为你的网站发布 AI 交互指南。

20. deep_research(10 credits)

全面的多来源研究(详见深度研究指南)。

Typescript
// Usage:
{
  "topic": "quantum computing commercialization",
  "maxUrls": 50,
  "enableSourceVerification": true,
  "enableConflictDetection": true
}

// Returns:
{
  "synthesis": "Comprehensive analysis...",
  "sources": [...],
  "conflicts": [...],
  "citations": [...]
}

何时使用: 研究项目、尽职调查、市场分析。

第四部分:集成指南

Claude Code 设置

Bash
# 1. Install CrawlForge MCP server
npm install -g crawlforge-mcp-server

# 2. Run setup wizard
npx crawlforge-setup

# 3. Add to Claude Code
claude
> /mcp add crawlforge npx crawlforge-mcp-server

# 4. Verify
> /mcp list
# Should show: crawlforge (26 tools)

Claude Desktop 设置

编辑你的 Claude Desktop 配置文件:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

Json
{
  "mcpServers": {
    "crawlforge": {
      "command": "npx",
      "args": ["crawlforge-mcp-server"],
      "env": {
        "CRAWLFORGE_API_KEY": "cf_live_your_key_here"
      }
    }
  }
}

自定义应用集成

Typescript
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";

const transport = new StdioClientTransport({
  command: "npx",
  args: ["crawlforge-mcp-server"],
  env: {
    CRAWLFORGE_API_KEY: process.env.CRAWLFORGE_API_KEY
  }
});

const client = new Client({
  name: "my-app",
  version: "1.0.0"
});

await client.connect(transport);

// List available tools
const tools = await client.listTools();
console.log(`Available tools: ${tools.tools.length}`);

// Call a tool
const result = await client.callTool({
  name: "fetch_url",
  arguments: {
    url: "https://example.com"
  }
});

第五部分:最佳实践

credits 优化

目标高成本高效
检查页面是否存在deep_research (10)fetch_url (1)
获取文章正文scrape_with_actions (5)extract_content (2)
查找竞品 URLsearch_web × 10 (50)extract_links (1)
抓取 20 个产品页面fetch_url × 20 (20)batch_scrape (5)

错误处理

Typescript
// Always handle failures gracefully
try {
  const result = await fetchUrl(url);
  if (result.status >= 400) {
    // Try with stealth mode
    return await stealthMode(url);
  }
  return result;
} catch (error) {
  // Log and retry with exponential backoff
  await sleep(retryDelay * attempt);
  return retry(url, attempt + 1);
}

速率限制

尊重目标站点:

Typescript
// Good: Reasonable delays
for (const url of urls) {
  await scrape(url);
  await sleep(1000 + Math.random() * 2000);  // 1-3s delay
}

// Better: Use batch_scrape with built-in rate limiting
await batchScrape(urls, { delayBetweenRequests: 1500 });

缓存

不要重复抓取同一个 URL:

Typescript
const cache = new Map<string, ScrapedContent>();

async function smartScrape(url: string) {
  if (cache.has(url)) {
    return cache.get(url);
  }

  const result = await fetchUrl(url);
  cache.set(url, result);
  return result;
}

第六部分:MCP 抓取的未来

新兴趋势

  1. AI 原生提取 —— LLM 直接解析非结构化 HTML
  2. 自愈型 scraper —— AI 自动适应站点变化
  3. 语义搜索 —— 用自然语言查询抓取到的数据
  4. 跨站分析 —— AI 在多个来源之间关联信息

CrawlForge 路线图

2026 年即将推出:

  • 实时监控 —— 即时的变更通知
  • AI schema 生成 —— 自动生成提取模板
  • 跨工具工作流 —— 智能地串联工具
  • 增强隐私 —— 零知识抓取选项

快速上手

准备好开始 MCP web scraping 了吗?这是你的路径:

免费套餐(非常适合入门)

  • 一次性 1,000 个试用 credits
  • 全部 26 个工具可用
  • 无需信用卡
Bash
# Quick start
npm install -g crawlforge-mcp-server
npx crawlforge-setup
# Visit: https://crawlforge.dev/signup

1,000 个 credits 能做些什么

使用场景工具Credits每月容量
基础抓取fetch_url11,000 个页面
文章提取extract_content2500 篇文章
站点测绘map_site2500 个站点
批量任务batch_scrape5200 个批次(1 万个 URL)
研究项目deep_research10100 个主题

总结

MCP 彻底变革了面向 AI 应用的 web scraping。关键要点:

  1. MCP 是标准 —— 所有主流 AI 助手都支持它
  2. CrawlForge 凭借 26 个工具领先 —— 是替代方案的 4 倍
  3. 从简单入手 —— 在使用进阶工具前,先用 fetch_url(1 credit)
  4. 组合工具 —— 串联多个操作以构建强大的工作流
  5. 保持合规 —— 尊重 robots.txt 和速率限制

相关资源:

  • CrawlForge 与 Firecrawl 对比
  • 构建竞争情报 agent
  • 隐身模式技术指南
  • 深度研究自动化
  • 官方文档

免费开始 | 查看定价 | 阅读文档

亲自试一试——无需注册

在 Playground 中运行 CrawlForge 的 27 个抓取与提取工具中的任意一个,然后免费开始,获取 1,000 credits。

1,000 免费 credits • 每月补充 • 无需信用卡

标签

mcpguideweb-scrapingtutorialmcp-web-scrapermodel-context-protocol

关于作者

C

CrawlForge Team

工程团队

我们正在打造功能最全面的 Web 抓取 MCP server。我们开发的工具帮助开发者为 AI 应用提取、分析和转换 Web 数据。

及时获取最新洞察

将教程、产品更新与 Web 抓取技巧直接发送到你的收件箱。

拒绝垃圾邮件,随时可取消订阅。

付诸实践

在任意 URL 上测试 CrawlForge 的工具——免费,无需注册。

本页内容

Frequently Asked Questions

什么是 MCP web scraping?+

MCP web scraping 使用 Model Context Protocol —— Anthropic 推出的开放标准 —— 让 Claude 等 AI 助手通过 JSON-RPC 连接到抓取工具。你无需编写 REST 集成,只需注册一个 MCP server,Claude 便会以它使用内置能力的方式发现并调用其抓取工具。

2026 年有哪些 MCP web scraper 可用?+

有多个 MCP server 提供抓取能力,但 CrawlForge 凭借 26 个工具领先 —— 大约是替代方案的 4 倍。其他服务器侧重于更狭窄的场景(基础抓取、特定平台),而 CrawlForge 在一个 server 中涵盖了抓取、提取、搜索、深度研究、隐身和变更跟踪。

Claude 如何发现并调用 CrawlForge 的工具?+

在 Claude Code 或 Claude Desktop 中配置后,MCP server 会以名称、描述和输入 schema 注册其工具。随后 Claude 通过 JSON-RPC 的 `tools/call` 消息调用工具,传入参数并接收结构化响应 —— 无需任何自定义客户端代码。

如何利用 CrawlForge 的 26 个工具优化 credits?+

永远从能解决问题的最便宜工具入手:fetch_url 和 extract_text 为 1 credit,scrape_structured 和 extract_content 为 2,进阶工具为 3-5,deep_research 为 10。缓存结果、批量处理 URL、串联操作,而不要在 fetch_url 就够用时去调用 deep_research。

免费套餐给我多少 credits?+

CrawlForge 的免费套餐包含一次性 1,000 个 credits,可使用全部 26 个工具,且无需信用卡。这大约可支持 1,000 次基础抓取、500 次结构化抓取,或 100 次 deep_research 查询 —— 足以构建并验证一整套 MCP 抓取工作流。

相关文章

网页抓取:2026 年 Python 对比 MCP
Web Scraping

网页抓取:2026 年 Python 对比 MCP

将 Python 抓取(requests、BeautifulSoup、Scrapy)与基于 MCP 的抓取进行对比。并排代码、性能基准,以及何时使用各自的方案。

C
CrawlForge Team
|
4月29日
|
10 分钟
2026 年最佳网页爬取工具:权威指南
Web Scraping

2026 年最佳网页爬取工具:权威指南

对比 2026 年的 12 款网页爬取工具,包括 CrawlForge、Firecrawl、Apify 和 Scrapy。涵盖功能、定价以及针对各类用例的推荐。

C
CrawlForge Team
|
4月25日
|
10 分钟
CrawlForge 与 Firecrawl 对比:哪款 MCP 网页抓取工具适合你?
Web Scraping

CrawlForge 与 Firecrawl 对比:哪款 MCP 网页抓取工具适合你?

全面对比 CrawlForge 与 Firecrawl 这两款 MCP server。比较功能、价格和能力,为 AI 选出最合适的网页抓取工具。

C
CrawlForge Team
|
1月20日
|
8 分钟

页脚

CrawlForge

面向 AI Agent 的企业级网页抓取。27 个专业 MCP 工具,专为构建智能系统的现代开发者而设计。

产品

  • 功能
  • Playground
  • 价格
  • 应用场景
  • 集成
  • 替代方案
  • 更新日志

资源

  • 快速上手
  • API 参考
  • 模板
  • 指南
  • 博客
  • 术语表
  • 常见问题
  • 网站地图

开发者

  • MCP 协议
  • Claude Desktop
  • Cursor IDE
  • LangChain
  • LlamaIndex

公司

  • 关于我们
  • 联系我们
  • 隐私政策
  • 服务条款
  • 可接受使用政策
  • Cookie

保持更新

获取新工具和新功能的最新动态。

基于 Next.js 和 MCP 协议构建

© 2025-2026 CrawlForge。保留所有权利。