本页内容
Claude 在阅读、推理和总结网页内容方面表现出色——但开箱即用时,它连一个实时页面都无法获取。只有用 Model Context Protocol(MCP)补上这道鸿沟,用 Claude 进行网页抓取才成为可能。接入 CrawlForge MCP 后,Claude 即可按需调用 23 个抓取工具:获取 URL、提取干净的文章正文、用 CSS 选择器拉取结构化数据、绕过反爬虫系统,或运行多源深度研究。无需 Python,无需 Playwright 样板代码,完全不用写抓取代码。
这是涵盖所有 Claude 网页抓取工作流的导航指南。无论你使用 Claude Desktop、终端里的 Claude Code,还是直接调用 Anthropic API,本页都会展示对应的设置方法,并链接到每条路径的深入教程。
快速开始:2 分钟完成设置
你只需要三样东西:Node.js 18+、一个 Claude 入口(Desktop、Code 或 API 访问权限),以及一个免费的 CrawlForge API key。在 crawlforge.dev/signup 注册——即可获得 1,000 credits,无需信用卡。
对于 Claude Desktop,把 CrawlForge 添加到你的配置文件:
{
"mcpServers": {
"crawlforge": {
"command": "npx",
"args": ["-y", "@crawlforge/mcp-server"],
"env": {
"CRAWLFORGE_API_KEY": "cf_live_YOUR_API_KEY_HERE"
}
}
}
}对于 Claude Code,最快的方式是使用设置向导:
npm install -g crawlforge-mcp-server
npx crawlforge-setup # paste your cf_live_ key when prompted重启 Claude,就可以开始抓取了。直接这样问它:"Fetch https://news.ycombinator.com and give me the top 5 story titles." Claude Desktop 在包括 Free 在内的所有套餐上都支持 MCP server;Claude Code 需要付费的 Claude 套餐或 API 计费——无论哪种方式,都不需要单独的抓取订阅。本指南的其余部分将解释每条路径的工作原理,以及你能用它构建什么。
目录
- Claude 如何抓取网页
- Claude Desktop 设置
- Claude Code 设置
- Claude API:构建你自己的智能体
- 你能构建什么
- 抓取受保护和重度依赖 JavaScript 的网站
- Credits 与费用
- 常见问题
Claude 如何抓取网页
Claude 没有原生的网络访问能力。让模型「读一下这个页面」,它会告诉你它无法打开 URL——它的知识止步于训练截止日期。用 Claude 抓取网页的原理,是给模型提供可以调用的工具,而这些工具的标准就是 Model Context Protocol。
MCP 是 Anthropic 用于把 AI 助手连接到外部系统的开放标准。MCP server 会公布一组工具(每个工具都有名称、描述和 JSON 输入 schema);客户端(Claude Desktop、Claude Code 或你自己的 API 循环)把这些工具展示给模型。当某个提示需要实时数据时,Claude 会发出一个结构化的工具调用,客户端执行它,结果再流回对话中。如果你刚接触这个协议,可以先读我们的面向开发者的 MCP 协议详解。
CrawlForge 是一个专为网页抓取打造的 MCP server。它没有提供单一的通用「fetch」函数,而是暴露了 23 个专门工具——从 fetch_url(原始 HTML,1 credit)到 deep_research(多源综合,10 credits)。Claude 会为每个请求自动挑选合适的工具。完整的架构和工具目录,请阅读 MCP 网页抓取完整指南。
关键的心智模型是:你用自然语言描述想要的结果,由 Claude 来编排工具。 你从不编写抓取脚本。是获取、提取、爬取还是研究,由 Claude 自行决定——任务需要多个步骤时,它还会把工具串联起来。
Claude Desktop 设置
Claude Desktop 是无需终端的路径。它从一个 JSON 文件读取 MCP server 配置,并通过聊天界面暴露这些工具。如果你想在不写任何代码的情况下以对话方式抓取,这是最佳选择。
配置文件位于:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
把上面快速开始中的 CrawlForge 配置块加进去,用你的 cf_live_ key 替换占位符,然后完全退出 Claude Desktop(不只是关闭窗口)并重新打开。server 加载后,输入框中会出现一个工具图标。用下面的提示测试:
Extract the main content from https://example.com and summarize it in three bullets.
Claude 会调用 extract_content(2 credits),返回没有广告和导航栏的干净正文。完整教程——包括排查「no tools found」错误和五个实操示例提示——请参阅如何为 Claude Desktop 添加网页抓取能力。
Claude Code 设置
Claude Code 是 Anthropic 的终端智能体。它可以编辑文件、运行 shell 命令、编写测试——但和 Desktop 一样,在接入 MCP server 之前它无法获取实时页面。注册 CrawlForge 之后,Claude Code 就能在一个会话里完成抓取、把结果存盘并直接喂给代码。
全局安装 server 并运行向导:
npm install -g crawlforge-mcp-server
crawlforge-mcp-server --version
# crawlforge-mcp-server 3.0.16
npx crawlforge-setup # writes the MCP entry and stores your key重启 Claude Code,然后确认连接:
/mcp
你应该能看到 crawlforge 显示为已连接,其工具均可用。现在让 Claude Code 抓取:"Fetch https://news.ycombinator.com and return the top 5 stories as a JSON array." 它会调用 fetch_url(1 credit),解析 HTML,并写出有效的 JSON。
如果你是 Claude Code 的新手,新手安装指南一步步讲解了 Node 设置、手动配置文件和 /mcp add 命令。想要以任务为导向的实操——先抓取一个定价页,再升级到 JavaScript 渲染的网站——请阅读如何用 Claude Code 抓取网站。
Claude API:构建你自己的智能体
如果你在构建产品而不是交互式地工作,可以完全跳过 Desktop 和 Code,把 CrawlForge 接入 Anthropic Claude API。该 API 支持原生工具调用:你把一组工具定义传给 Claude,模型返回结构化的 tool_use 块,由你的代码去调用 CrawlForge REST API 执行。
循环非常简单:发送用户提示和工具定义,收到 tool_use 块,调用 CrawlForge,返回 tool_result,让 Claude 继续。下面是它的 TypeScript 核心实现:
import Anthropic from '@anthropic-ai/sdk';
const claude = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
// Call the CrawlForge REST API for a given tool
async function runCrawlForgeTool(name: string, input: Record<string, unknown>) {
const res = await fetch(`https://crawlforge.dev/api/v1/tools/${name}`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.CRAWLFORGE_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(input),
});
return res.json();
}
const message = await claude.messages.create({
model: 'claude-sonnet-4-6',
max_tokens: 1024,
tools: [
{
name: 'extract_content',
description: 'Extract clean readable content from a web page. Costs 2 credits.',
input_schema: {
type: 'object',
properties: { url: { type: 'string', description: 'The URL to read' } },
required: ['url'],
},
},
],
messages: [
{ role: 'user', content: 'What is on the Hacker News front page right now?' },
],
});
// When Claude returns a tool_use block, execute it and feed the result back
const toolUse = message.content.find((b) => b.type === 'tool_use');
if (toolUse && toolUse.type === 'tool_use') {
const result = await runCrawlForgeTool(toolUse.name, toolUse.input as Record<string, unknown>);
console.log(result); // feed this back as a tool_result to continue the conversation
}这个模式可以从单个工具扩展到全部 23 个。完整的生产级版本——定义多个工具 schema、处理多轮工具调用循环、流式响应——见如何在 Anthropic Claude API 中使用 CrawlForge。
你能构建什么
设置只是无聊的开头。下面才是用 Claude 抓取网页真正解锁的能力,附上你今天就能直接粘贴的示例提示。
1. 研究助手
把 Claude 指向一个主题,让它跨来源搜索、获取并综合信息,而不是凭过时的训练数据瞎猜。
Research "state of WebGPU browser support in 2026". Search the web, read the top
sources, and give me a 5-bullet summary with a citation link after each bullet.
Claude 会把 search_web(5 credits)与每个来源各一次的 extract_content(每次 2 credits)串联起来。完整项目——提示设计、来源排序和引用格式——见用 Claude 和 MCP 构建 AI 研究助手。
2. 竞争情报智能体
追踪竞品页面——定价、功能列表、更新日志——让 Claude 标出发生了什么变化。
Scrape the pricing pages for these three competitors and build a comparison table
of plan name, monthly price, and included seats. Highlight anything cheaper than ours.
Claude 使用 scrape_structured(2 credits)进行干净的表格化提取。端到端的构建过程见用 Claude 和 CrawlForge 构建竞争情报智能体。
3. 针对单个问题的深度研究
当一个问题需要广度和来源核实,而不是快速查一下就够时,把它交给 deep_research。
Do deep research on "regulatory changes affecting EU AI startups in 2026" and
return a structured report with conflicting viewpoints noted.
这一个工具(10 credits)就能完成搜索、获取、交叉核对,并附带引用地综合结论。想了解它的底层工作方式,请阅读深度研究功能介绍。
4. 自动化价格监控
把抓取和变更追踪结合起来,让 Claude 在价格变动时告诉你——而不用你自己反复重读所有页面。
Set up a daily check on this product page. Extract the current price and alert me
only when it drops below $80.
Claude 会把 scrape_structured(2 credits)和 track_changes(3 credits)配合使用。完整系统——选择器、调度和告警——见构建 AI 价格监控系统。
抓取受保护和重度依赖 JavaScript 的网站
许多网站要么用客户端 JavaScript 渲染内容,要么躲在 Cloudflare、DataDome 或 PerimeterX 这类反爬虫系统后面。一次普通的 fetch_url 只会返回空壳页面或验证挑战页。针对这些场景,CrawlForge 为 Claude 提供了两个升级工具。
scrape_with_actions(5 credits)驱动一个真实浏览器:它可以等待内容加载、点击按钮、填写表单并滚动页面,然后再提取。适用于单页应用,以及需要登录或交互才能访问的内容。
stealth_mode(5 credits)增加了指纹随机化、住宅代理轮换和人类行为模拟,用来绕过原本公开页面上的机器人检测。
This pricing page is behind Cloudflare and loads its table with JavaScript. Use
stealth mode to load it, wait for the pricing table to render, then extract the
plan names and prices into JSON.
正确的顺序是:先试 fetch_url(1 credit——很多「受保护」的页面对格式规范的请求照样返回内容),再逐级升级。指纹轮换的取舍以及每个工具各自的适用场景,请参阅我们的隐身模式深度解析。一个诚实的限制:CrawlForge 不会破解交互式 CAPTCHA,也不会抓取你没有付费的付费墙内容——你也不应该要求它这么做。
Credits 与费用
CrawlForge 采用 credit 模式:每次工具调用扣除固定数量的 credits,所以便宜的操作始终便宜。以下是每个工具的真实费用。
| Credits | 工具 |
|---|---|
| 0 | list_ollama_models |
| 1 | fetch_url、extract_text、extract_links、extract_metadata、scrape_template |
| 2 | scrape_structured、extract_content、map_site、process_document、localization |
| 3 | track_changes、analyze_content、extract_structured、extract_with_llm |
| 4 | summarize_content、crawl_deep |
| 5 | stealth_mode、scrape_with_actions、batch_scrape、search_web、generate_llms_txt |
| 10 | deep_research |
套餐决定每月的 credit 额度:
| 套餐 | 价格 | Credits | 适合 |
|---|---|---|---|
| Free | $0 | 1,000(一次性) | 试用与轻量个人使用 |
| Hobby | $19/月 | 5,000/月 | 业余项目与日常抓取 |
| Professional | $99/月 | 50,000/月 | 生产环境智能体与团队 |
| Business | $399/月 | 250,000/月 | 带 SLA 的大规模流水线 |
两个习惯能让成本保持低位。第一,优先用能完成任务的最便宜工具——已经知道 URL 时,用 fetch_url(1 credit)而不是 search_web(5 credits)。第二,处理大量 URL 时用 batch_scrape(5 credits),而不是逐个发起调用。完整明细见价格页面,你还可以在控制台查看用量。
准备好开始了吗?
用 Claude 抓取网页只需大约两分钟的设置,零行抓取代码。选择你的路径——Claude Desktop、Claude Code 或 Claude API——接入 CrawlForge,让 Claude 按需从 23 个工具中挑选。
用 1,000 个免费 credits 免费开始——无需信用卡。