firecrawl/firecrawl
The context API to search, scrape, and interact with the web at scale. 🔥
firecrawl/firecrawl
The context API to search, scrape, and interact with the web at scale. 🔥
Firecrawl 是面向 AI 应用的网页上下文 API:把搜索、单页抓取、全站爬取、站点地图发现与页面交互收成一套接口,输出干净 Markdown、结构化 JSON 或截图,供 Agent 与 RAG 流水线直接消费。项目以 AGPL-3.0 开源,可自托管;日常最快路径是 Firecrawl Cloud 托管服务。官方文档见 docs.firecrawl.dev。
Search 搜网并带回全文、Scrape 把任意 URL 转成 Markdown/HTML/JSON、Crawl 整站抓取、Map 秒级发现站点 URL、Batch Scrape 异步批量处理firecrawl-mcp 接入任意 MCP 客户端给模型喂网页时,最耗时间的往往不是写 prompt,而是代理轮换、JS 渲染、反爬、站点发现与正文清洗。Firecrawl 把这些收成一次 API 调用:你给 URL 或自然语言任务,拿回可直接进向量库或 Agent 上下文的 Markdown/JSON。托管版适合快速上线;需要源码与基础设施控制时,可用 Docker Compose 自托管开源栈。Playground 可先验证目标站点效果,再决定是否接入生产。
r.jina.ai/ 前缀即可把单页转成 Markdown,原型最快;Firecrawl 额外提供整站 crawl、map、search、交互与 schema 抽取,更适合生产级 Agent。fc- 开头的 API Key;可用 Playground 先试目标站点。pip。3002。官方评估指南以发布标签 v2.11.162 为准,换版本前先对照该版 docker-compose.yaml。方式一:Python SDK(托管 API)
pip install firecrawl-py方式二:Node.js SDK
npm install firecrawl方式三:给 Agent / MCP 接入
npx -y firecrawl-cli@latest init --all --browserMCP 客户端示例(需设置 FIRECRAWL_API_KEY):
{ "mcpServers": { "firecrawl-mcp": { "command": "npx", "args": ["-y", "firecrawl-mcp"], "env": { "FIRECRAWL_API_KEY": "fc-YOUR_API_KEY" } } }}方式四:Docker Compose 自托管(评估用)
git clone https://github.com/firecrawl/firecrawl.gitcd firecrawlgit checkout v2.11.162在仓库根目录写入最小 .env(勿提交;将密码换成至少 32 位随机字符,并保持 POSTGRES_DB=postgres):
cat > .env <<'EOF'USE_DB_AUTHENTICATION=falsePOSTGRES_USER=postgresPOSTGRES_PASSWORD=replace-with-at-least-32-random-charactersPOSTGRES_DB=postgresEOFdocker compose up --build -d该基线关闭 API 鉴权,仅适合受信网络评估,不是生产架构。完整步骤见 Self-hosting 文档。
托管版用 Python 抓取一页:
from firecrawl import Firecrawl
app = Firecrawl(api_key="fc-YOUR_API_KEY")doc = app.scrape("https://firecrawl.dev", formats=["markdown"])print(doc.markdown)等价 cURL:
curl -X POST 'https://api.firecrawl.dev/v2/scrape' \ -H 'Authorization: Bearer fc-YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{"url": "https://firecrawl.dev", "formats": ["markdown"]}'自然语言取数(Cloud Agent 端点,无需事先知道 URL):
curl -X POST 'https://api.firecrawl.dev/v2/agent' \ -H 'Authorization: Bearer fc-YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{"prompt": "Find the pricing plans for Notion"}'自托管冒烟(鉴权关闭时无需 Bearer):
curl --fail --silent --show-error --max-time 5 \ http://localhost:3002/v0/health/readinesssuccess: true 与非空 markdown(或 SDK 的 doc.markdown)。sources 列表,而不是空对象。{"status":"ok"};再对 https://example.com 发 POST /v2/scrape,确认 data.markdown 与 metadata.statusCode 为 200。健康检查只证明进程存活,不能代替一次真实抓取。USE_DB_AUTHENTICATION=false 时请求不需要 API Key,切勿把 3002 暴露到公网。Compose 基线也没有持久化卷、TLS 与高可用。spark-1-mini(默认、更便宜)或 spark-1-pro(复杂调研)。大批量前先在 Playground 估消耗。robots.txt;抓取目标站点须遵守其条款与隐私政策,责任在使用者。redis://redis:6379,容器里写 localhost 会连到自己而不是 Redis 服务。