微信扫码
添加专属顾问
我要投稿
掌握Firecrawl,高效获取网站数据。核心内容:1. Firecrawl云爬取服务介绍及其开源版本2. 单一URL爬取功能及复杂内容处理能力3. 批量爬取多个URL的方法和SDK调用示例
Firecrawl是一个云爬取服务,可以无需网站地图的情况下爬取整个网站内容、单个网页、网站地图;通过内置LLM实现自然语言对爬取内容的抽取。同时,Firecrawl也有对应的开源版本,可以自行下载开源代码并运行。
将任何 URL 转换为干净数据
Firecrawl 将网页转换为 markdown,非常适合 LLM 应用程序。
它管理复杂性:代理、缓存、速率限制、js 阻止的内容 处理动态内容:动态网站、js 渲染的网站、PDF、图像 输出干净的 markdown、结构化数据、屏幕截图或 html。 调用端点如下:
curl --request POST \
--url https://host:port/v1/scrape \
--header 'Content-Type: application/json' \
--data '{
"url": "<string>",
"formats": [
"markdown"
],
"onlyMainContent": true,
"includeTags": [
"<string>"
],
"excludeTags": [
"<string>"
],
"headers": {},
"waitFor": 0,
"mobile": false,
"skipTlsVerification": false,
"timeout": 30000,
"jsonOptions": {
"schema": {},
"systemPrompt": "<string>",
"prompt": "<string>"
},
"actions": [
{
"type": "wait",
"milliseconds": 2,
"selector": "#my-element"
}
],
"location": {
"country": "US",
"languages": [
"en-US"
]
},
"removeBase64Images": true,
"blockAds": true,
"proxy": "basic"
}'
可以同时批量抓取多个 URL。它以起始 URL 和可选参数作为参数。params 参数允许您为批量抓取作业指定其他选项,例如输出格式。
它的工作方式与端点非常相似/crawl。它提交批量抓取作业并返回作业 ID 以检查批量抓取的状态。
SDK 提供两种方法:同步和异步。同步方法将返回批量抓取作业的结果,而异步方法将返回一个作业 ID,您可以使用该 ID 检查批量抓取的状态。
curl --request POST \
--url https://host:port/v1/batch/scrape \
--header 'Content-Type: application/json' \
--data '{
"urls": [
"<string>"
],
"webhook": {
"url": "<string>",
"headers": {},
"metadata": {},
"events": [
"completed"
]
},
"ignoreInvalidURLs": false,
"formats": [
"markdown"
],
"onlyMainContent": true,
"includeTags": [
"<string>"
],
"excludeTags": [
"<string>"
],
"headers": {},
"waitFor": 0,
"mobile": false,
"skipTlsVerification": false,
"timeout": 30000,
"jsonOptions": {
"schema": {},
"systemPrompt": "<string>",
"prompt": "<string>"
},
"actions": [
{
"type": "wait",
"milliseconds": 2,
"selector": "#my-element"
}
],
"location": {
"country": "US",
"languages": [
"en-US"
]
},
"removeBase64Images": true,
"blockAds": true,
"proxy": "basic"
}'
使用 Firecrawl 抓取并提取结构化数据 Firecrawl 利用大型语言模型 (LLM) 高效地从网页中提取结构化数据。具体方法如下:
该方法简化了数据提取,减少了手动处理并提高了效率。
curl -X POST https://host:port/v1/scrape \
-H 'Content-Type: application/json' \
-d '{
"url": "https://docs.firecrawl.dev/",
"formats": ["json"],
"jsonOptions": {
"schema": {
"type": "object",
"properties": {
"company_mission": {
"type": "string"
},
"supports_sso": {
"type": "boolean"
},
"is_open_source": {
"type": "boolean"
},
"is_in_yc": {
"type": "boolean"
}
},
"required": [
"company_mission",
"supports_sso",
"is_open_source",
"is_in_yc"
]
}
}
}'
只需将 传递给端点即可提取数据,而无需使用模式prompt。
curl -X POST https://host:port/v1/scrape \
-H 'Content-Type: application/json' \
-d '{
"url": "https://docs.firecrawl.dev/",
"formats": ["json"],
"jsonOptions": {
"prompt": "Extract the company mission from the page."
}
}'
Firecrawl 可以递归搜索 URL 子域,并收集内容
Firecrawl 会彻底抓取网站,确保全面提取数据,同时绕过任何网络拦截机制。其工作原理如下:
此方法保证从任何起始 URL 进行详尽的抓取和数据收集。
curl -X POST https://host:port/v1/crawl \
-H 'Content-Type: application/json' \
-d '{
"url": "https://docs.firecrawl.dev",
"limit": 100,
"scrapeOptions": {
"formats": ["markdown", "html"]
}
}'
输入一个网站并获取该网站上的所有网址 - 速度极快
这是将单个 URL 转换为整个网站地图的最简单方法。此功能在以下情况下非常有用:
当你需要提示最终用户选择要抓取的链接时 需要快速了解网站上的链接 需要抓取与特定主题相关的网站页面(使用search参数) 只需抓取网站的特定页面
curl -X POST https://host:port/v1/map \
-H 'Content-Type: application/json' \
-d '{
"url": "https://firecrawl.dev"
}'
该/extract端点简化了从任意数量的 URL 或整个域收集结构化数据的过程。只需提供一个 URL 列表(可选使用通配符,例如example.com/*),以及描述所需信息的提示符或架构即可。Firecrawl 负责抓取、解析和整理大型或小型数据集的细节。
使用/extract 您可以从一个或多个 URL 中提取结构化数据,包括通配符:
单页 示例:https://firecrawl.dev/some-page 多页面/完整域名 示例:https://firecrawl.dev/* 当您使用 时/*,Firecrawl 会自动抓取并解析其在该域名下发现的所有 URL,然后提取请求的数据。
curl -X POST https://host:port/v1/extract \
-H 'Content-Type: application/json' \
-d '{
"urls": [
"https://firecrawl.dev/",
"https://docs.firecrawl.dev/",
"https://www.ycombinator.com/companies"
],
"prompt": "Extract the company mission, whether it supports SSO, whether it is open source, and whether it is in Y Combinator from the page.",
"schema": {
"type": "object",
"properties": {
"company_mission": {
"type": "string"
},
"supports_sso": {
"type": "boolean"
},
"is_open_source": {
"type": "boolean"
},
"is_in_yc": {
"type": "boolean"
}
},
"required": [
"company_mission",
"supports_sso",
"is_open_source",
"is_in_yc"
]
}
}'
Firecrawl 是开源的,根据AGPL-3.0 许可提供。 Firecrawl Cloud 可在firecrawl.dev上获取,云托管提供一系列开源版本所没有的功能。
开源版本和云版本之间的差异,如下图所示:
支持单网页爬取的scrape
支持正站爬取的crawl
支持通过LLM进行Extract
支持爬取站点地图sitemap
5.支持输出LLM友好的格式,markwon,json等
7. 绕过机器人保护
代理轮换
爬取控制台
10.内容交互和点击执行
11.无头浏览器
12.企业版的一些其他特征
Quickstart | Firecrawl
Blog
Firecrawl
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费场景POC验证,效果验证后签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2025-04-13
3 周 3000 人 Star!让电脑自己干活。
2025-04-13
我对多Agent平台的进一步升级和落地范式
2025-04-13
微软开源PIKE-RAG:专业领域RAG系统新标杆,多步推理准确率提升30%!
2025-04-13
揭秘BizGen:2.7B参数模型助力商业文案生成,效率提升3倍
2025-04-13
AI 大模型评测难?OpenCompass 这个‘自动跑分神器’来破局!
2025-04-13
Google ADK,知多少?
2025-04-13
微软PIKE-RAG开源:L0 到 L4级分阶段系统构建策略
2025-04-13
15个最佳开源 RAG 框架选型指南
2025-01-01
2024-07-25
2025-01-21
2024-05-06
2024-09-20
2024-07-20
2024-06-12
2024-07-11
2024-08-13
2024-12-26
2025-04-13
2025-04-10
2025-04-07
2025-04-03
2025-04-03
2025-04-03
2025-04-01
2025-03-31