跳转到主要内容
POST
/
crawl
根据参数爬取多个 URL
curl --request POST \
  --url https://api.firecrawl.dev/v2/crawl \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "url": "<string>",
  "prompt": "<string>",
  "excludePaths": [
    "<string>"
  ],
  "includePaths": [
    "<string>"
  ],
  "maxDiscoveryDepth": 123,
  "sitemap": "include",
  "ignoreQueryParameters": false,
  "limit": 10000,
  "crawlEntireDomain": false,
  "allowExternalLinks": false,
  "allowSubdomains": false,
  "delay": 123,
  "maxConcurrency": 123,
  "webhook": {
    "url": "<string>",
    "headers": {},
    "metadata": {},
    "events": [
      "completed"
    ]
  },
  "scrapeOptions": {
    "formats": [
      "markdown"
    ],
    "onlyMainContent": true,
    "includeTags": [
      "<string>"
    ],
    "excludeTags": [
      "<string>"
    ],
    "maxAge": 172800000,
    "headers": {},
    "waitFor": 0,
    "mobile": false,
    "skipTlsVerification": true,
    "timeout": 123,
    "parsers": [
      "pdf"
    ],
    "actions": [
      {
        "type": "wait",
        "milliseconds": 2,
        "selector": "#my-element"
      }
    ],
    "location": {
      "country": "US",
      "languages": [
        "en-US"
      ]
    },
    "removeBase64Images": true,
    "blockAds": true,
    "proxy": "auto",
    "storeInCache": true
  },
  "zeroDataRetention": false
}
'
{
  "success": true,
  "id": "<string>",
  "url": "<string>"
}

v2 新增内容

指定爬取目标

用简洁的英文描述你想爬取的内容:
{
  "url": "https://example.com",
  "prompt": "只抓取博客文章和文档,跳过营销页"
}
这会将提示映射到一组爬虫设置,以执行抓取。

改进的 Sitemap 控制

在 v1 中,是否使用 sitemap 由一个布尔值控制。在 v2 中,sitemap 选项允许你选择:
  • "include"(默认):使用 sitemap,同时发现其他页面。
  • "skip":完全忽略 sitemap。

新的爬取选项

  • crawlEntireDomain - 爬取整个域,而不仅限于子页面
  • maxDiscoveryDepth - 控制发现深度(替代 maxDepth
{
  "url": "https://example.com/features",
  "crawlEntireDomain": true,
  "maxDiscoveryDepth": 2,
  "sitemap": "include"
}

授权

Authorization
string
header
必填

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

请求体

application/json
url
string<uri>
必填

用于开始爬取的基础 URL

prompt
string

用于根据自然语言生成爬虫选项(包括下方的所有参数)的提示词。显式指定的参数会覆盖生成的对应参数。

excludePaths
string[]

用于将匹配的 URL 排除在爬取之外的 URL 路径名正则表达式模式。例如,如果你为基础 URL firecrawl.dev 设置 "excludePaths": ["blog/.*"],那么所有匹配该模式的结果都会被排除,例如:https://www.firecrawl.dev/blog/firecrawl-launch-week-1-recap。

includePaths
string[]

用于在抓取中指定要包含哪些 URL 的 URL 路径名正则表达式模式。只有路径与指定模式匹配的 URL 才会出现在响应中。比如,如果你为基础 URL firecrawl.dev 设置 "includePaths": ["blog/.*"],则只有匹配该模式的结果会被返回,例如:https://www.firecrawl.dev/blog/firecrawl-launch-week-1-recap。

maxDiscoveryDepth
integer

根据页面被发现的顺序设定的最大爬取深度。根站点和 sitemap 中的页面的发现深度为 0。比如,如果你将其设置为 1,并将 sitemap 设置为 'skip',则只会爬取你输入的 URL 以及该页面上链接到的所有 URL。

sitemap
enum<string>
默认值:include

爬取时使用的 sitemap 模式。如果将其设置为「skip」,爬虫将忽略网站的 sitemap,只爬取你输入的 URL,并从该页面开始继续发现和爬取后续页面。

可用选项:
skip,
include
ignoreQueryParameters
boolean
默认值:false

不要对同一路径使用不同(或没有)查询参数重复抓取

limit
integer
默认值:10000

最大爬取页数。默认值为 10000。

crawlEntireDomain
boolean
默认值:false

允许爬虫不仅跟踪子路径,还能跟踪同级或父级的站内链接。

false:只爬取更深层(子级)URL。 → 例如 /features/feature-1 → /features/feature-1/tips ✅ → 不会跟踪 /pricing 或 / ❌

true:会爬取任意站内链接,包括同级和父级。 → 例如 /features/feature-1 → /pricing、/ 等 ✅

如需在嵌套路径之外更广泛地覆盖站内页面,请将其设置为 true。

允许爬虫通过链接访问外部网站。

allowSubdomains
boolean
默认值:false

允许爬虫通过链接继续爬取主域名下的子域名。

delay
number

两次抓取之间的延迟时间(以秒为单位)。有助于遵守网站的速率限制。

maxConcurrency
integer

最大并发抓取数量。此参数允许你为本次抓取设置并发上限。如果未指定,则本次抓取将遵循你所在团队的并发限制。

webhook
object

一个 Webhook 规范对象。

scrapeOptions
object
zeroDataRetention
boolean
默认值:false

如果设置为 true,将为本次抓取任务启用零数据保留。要启用此功能,请联系 [email protected]

响应

成功的响应

success
boolean
id
string
url
string<uri>