跳转到主要内容
POST
/
batch
/
scrape
抓取多个 URL,并可选择使用 LLM 提取信息
curl --request POST \
  --url https://api.firecrawl.dev/v2/batch/scrape \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "urls": [
    "<string>"
  ],
  "webhook": {
    "url": "<string>",
    "headers": {},
    "metadata": {},
    "events": [
      "completed"
    ]
  },
  "maxConcurrency": 123,
  "ignoreInvalidURLs": true,
  "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>",
  "invalidURLs": [
    "<string>"
  ]
}

授权

Authorization
string
header
必填

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

请求体

application/json
urls
string<uri>[]
必填

要爬取的 URL

webhook
object

Webhook 规范对象。

maxConcurrency
integer

最大并发抓取数。此参数用于为本次批量抓取设置并发上限。若未指定,批量抓取将遵循你的团队的并发限制。

ignoreInvalidURLs
boolean
默认值:true

如果在 urls 数组中指定了无效的 URL,这些 URL 会被忽略。它们不会导致整个请求失败,而是会使用剩余的有效 URL 创建一次批量抓取任务,并在响应的 invalidURLs 字段中返回这些无效的 URL。

formats
(Markdown · object | Summary · object | HTML · object | Raw HTML · object | Links · object | Images · object | Screenshot · object | JSON · object | Change Tracking · object | Branding · object)[]

要在响应中包含的输出 formats。你可以指定一个或多个 formats,既可以使用字符串(例如:'markdown'),也可以使用带有其他选项的对象(例如:{ type: 'json', schema: {...} })。某些 formats 需要配置特定选项。示例:['markdown', { type: 'json', schema: {...} }]

onlyMainContent
boolean
默认值:true

仅返回页面的主要内容,不包含 header、nav、footer 等元素。

includeTags
string[]

在输出中要包含的标签。

excludeTags
string[]

在输出中需要排除的标签。

maxAge
integer
默认值:172800000

如果页面的缓存版本的生成时间距今少于该毫秒数,则返回该缓存页面;如果缓存版本距今超过该时间,则会重新抓取页面。若你不需要特别新的数据,启用此选项可将抓取速度提升至 5 倍。默认值为 2 天。

headers
object

随请求发送的请求头。可用于传递 cookies、User-Agent 等信息。

waitFor
integer
默认值:0

指定在抓取内容前的延迟时间(毫秒),以便页面有足够时间完成加载。该等待时间是在 Firecrawl 的智能等待功能基础上的额外等待。

mobile
boolean
默认值:false

若要模拟在移动设备上进行抓取,请将其设置为 true。适用于测试响应式页面并获取移动端截图。

skipTlsVerification
boolean
默认值:true

在发起请求时跳过 TLS 证书验证。

timeout
integer

请求的超时时间(毫秒)。

parsers
object[]

用于控制在抓取过程中如何处理文件。包含 "pdf" 时(默认),会提取 PDF 内容并转换为 Markdown 格式,计费基于页数(每页 1 点数)。当传入空数组时,会以 base64 编码返回整个 PDF 文件,并对整份 PDF 按单一费率收取 1 点数。

actions
(Wait · object | Screenshot · object | Click · object | Write text · object | Press a key · object | Scroll · object | Scrape · object | Execute JavaScript · object | Generate PDF · object)[]

在抓取页面内容之前需要执行的页面 actions

location
object

请求的地理位置设置。指定后,如果有可用的代理,将使用合适的代理,并模拟相应的语言和时区设置。如果未指定,则默认为“US”。

removeBase64Images
boolean
默认值:true

从输出中移除所有 Base64 编码图片,以避免内容过于冗长。图片的 alt 文本会保留在输出中,但其 URL 会被占位符替换。

blockAds
boolean
默认值:true

启用广告拦截和 Cookie 弹窗拦截功能。

proxy
enum<string>
默认值:auto

指定要使用的代理类型。

  • basic:用于抓取未启用或仅启用基础反爬虫方案的网站的代理。速度快,通常有效。
  • stealth:用于抓取启用高级反爬虫方案的网站的隐匿代理。速度较慢,但在特定网站上更可靠。每个请求最多消耗 5 点积分。
  • auto:如果 basic 代理抓取失败,Firecrawl 会自动使用 stealth 代理重试抓取。如果使用 stealth 的重试成功,本次抓取将扣除 5 点积分;如果第一次使用 basic 即抓取成功,则只按常规费用计费。
可用选项:
basic,
stealth,
auto
storeInCache
boolean
默认值:true

如果为 true,该页面会存储到 Firecrawl 的索引和缓存中。如果你的抓取操作可能涉及数据保护方面的顾虑,将其设置为 false 会很有用。使用某些与敏感抓取相关的参数(例如 actions、headers)时,会被强制将此参数设为 false。

zeroDataRetention
boolean
默认值:false

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

响应

成功的响应

success
boolean
id
string
url
string<uri>
invalidURLs
string[] | null

如果 ignoreInvalidURLs 为 true,则该字段是一个数组,包含请求中指定的所有无效 URL。若没有无效 URL,则该数组为空。如果 ignoreInvalidURLs 为 false,则该字段为 undefined。