批量抓取
curl --request POST \
--url https://api.firecrawl.dev/v1/batch/scrape \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"urls": [
"<string>"
],
"maxConcurrency": 123,
"ignoreInvalidURLs": false,
"onlyMainContent": true,
"includeTags": [
"<string>"
],
"excludeTags": [
"<string>"
],
"maxAge": 0,
"headers": {},
"waitFor": 0,
"mobile": false,
"skipTlsVerification": false,
"timeout": 30000,
"parsePDF": true,
"jsonOptions": {
"schema": {},
"systemPrompt": "<string>",
"prompt": "<string>"
},
"actions": [
{
"type": "wait",
"milliseconds": 2,
"selector": "#my-element"
}
],
"location": {
"country": "US",
"languages": [
"en-US"
]
},
"removeBase64Images": true,
"blockAds": true,
"storeInCache": true,
"formats": [
"markdown"
],
"changeTrackingOptions": {
"modes": [],
"schema": {},
"prompt": "<string>",
"tag": null
},
"zeroDataRetention": false
}
'import requests
url = "https://api.firecrawl.dev/v1/batch/scrape"
payload = {
"urls": ["<string>"],
"maxConcurrency": 123,
"ignoreInvalidURLs": False,
"onlyMainContent": True,
"includeTags": ["<string>"],
"excludeTags": ["<string>"],
"maxAge": 0,
"headers": {},
"waitFor": 0,
"mobile": False,
"skipTlsVerification": False,
"timeout": 30000,
"parsePDF": True,
"jsonOptions": {
"schema": {},
"systemPrompt": "<string>",
"prompt": "<string>"
},
"actions": [
{
"type": "wait",
"milliseconds": 2,
"selector": "#my-element"
}
],
"location": {
"country": "US",
"languages": ["en-US"]
},
"removeBase64Images": True,
"blockAds": True,
"storeInCache": True,
"formats": ["markdown"],
"changeTrackingOptions": {
"modes": [],
"schema": {},
"prompt": "<string>",
"tag": None
},
"zeroDataRetention": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
urls: ['<string>'],
maxConcurrency: 123,
ignoreInvalidURLs: false,
onlyMainContent: true,
includeTags: ['<string>'],
excludeTags: ['<string>'],
maxAge: 0,
headers: {},
waitFor: 0,
mobile: false,
skipTlsVerification: false,
timeout: 30000,
parsePDF: true,
jsonOptions: {schema: {}, systemPrompt: '<string>', prompt: '<string>'},
actions: [{type: 'wait', milliseconds: 2, selector: '#my-element'}],
location: {country: 'US', languages: ['en-US']},
removeBase64Images: true,
blockAds: true,
storeInCache: true,
formats: ['markdown'],
changeTrackingOptions: {modes: [], schema: {}, prompt: '<string>', tag: null},
zeroDataRetention: false
})
};
fetch('https://api.firecrawl.dev/v1/batch/scrape', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.firecrawl.dev/v1/batch/scrape",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'urls' => [
'<string>'
],
'maxConcurrency' => 123,
'ignoreInvalidURLs' => false,
'onlyMainContent' => true,
'includeTags' => [
'<string>'
],
'excludeTags' => [
'<string>'
],
'maxAge' => 0,
'headers' => [
],
'waitFor' => 0,
'mobile' => false,
'skipTlsVerification' => false,
'timeout' => 30000,
'parsePDF' => true,
'jsonOptions' => [
'schema' => [
],
'systemPrompt' => '<string>',
'prompt' => '<string>'
],
'actions' => [
[
'type' => 'wait',
'milliseconds' => 2,
'selector' => '#my-element'
]
],
'location' => [
'country' => 'US',
'languages' => [
'en-US'
]
],
'removeBase64Images' => true,
'blockAds' => true,
'storeInCache' => true,
'formats' => [
'markdown'
],
'changeTrackingOptions' => [
'modes' => [
],
'schema' => [
],
'prompt' => '<string>',
'tag' => null
],
'zeroDataRetention' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.firecrawl.dev/v1/batch/scrape"
payload := strings.NewReader("{\n \"urls\": [\n \"<string>\"\n ],\n \"maxConcurrency\": 123,\n \"ignoreInvalidURLs\": false,\n \"onlyMainContent\": true,\n \"includeTags\": [\n \"<string>\"\n ],\n \"excludeTags\": [\n \"<string>\"\n ],\n \"maxAge\": 0,\n \"headers\": {},\n \"waitFor\": 0,\n \"mobile\": false,\n \"skipTlsVerification\": false,\n \"timeout\": 30000,\n \"parsePDF\": true,\n \"jsonOptions\": {\n \"schema\": {},\n \"systemPrompt\": \"<string>\",\n \"prompt\": \"<string>\"\n },\n \"actions\": [\n {\n \"type\": \"wait\",\n \"milliseconds\": 2,\n \"selector\": \"#my-element\"\n }\n ],\n \"location\": {\n \"country\": \"US\",\n \"languages\": [\n \"en-US\"\n ]\n },\n \"removeBase64Images\": true,\n \"blockAds\": true,\n \"storeInCache\": true,\n \"formats\": [\n \"markdown\"\n ],\n \"changeTrackingOptions\": {\n \"modes\": [],\n \"schema\": {},\n \"prompt\": \"<string>\",\n \"tag\": null\n },\n \"zeroDataRetention\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.firecrawl.dev/v1/batch/scrape")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"urls\": [\n \"<string>\"\n ],\n \"maxConcurrency\": 123,\n \"ignoreInvalidURLs\": false,\n \"onlyMainContent\": true,\n \"includeTags\": [\n \"<string>\"\n ],\n \"excludeTags\": [\n \"<string>\"\n ],\n \"maxAge\": 0,\n \"headers\": {},\n \"waitFor\": 0,\n \"mobile\": false,\n \"skipTlsVerification\": false,\n \"timeout\": 30000,\n \"parsePDF\": true,\n \"jsonOptions\": {\n \"schema\": {},\n \"systemPrompt\": \"<string>\",\n \"prompt\": \"<string>\"\n },\n \"actions\": [\n {\n \"type\": \"wait\",\n \"milliseconds\": 2,\n \"selector\": \"#my-element\"\n }\n ],\n \"location\": {\n \"country\": \"US\",\n \"languages\": [\n \"en-US\"\n ]\n },\n \"removeBase64Images\": true,\n \"blockAds\": true,\n \"storeInCache\": true,\n \"formats\": [\n \"markdown\"\n ],\n \"changeTrackingOptions\": {\n \"modes\": [],\n \"schema\": {},\n \"prompt\": \"<string>\",\n \"tag\": null\n },\n \"zeroDataRetention\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firecrawl.dev/v1/batch/scrape")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"urls\": [\n \"<string>\"\n ],\n \"maxConcurrency\": 123,\n \"ignoreInvalidURLs\": false,\n \"onlyMainContent\": true,\n \"includeTags\": [\n \"<string>\"\n ],\n \"excludeTags\": [\n \"<string>\"\n ],\n \"maxAge\": 0,\n \"headers\": {},\n \"waitFor\": 0,\n \"mobile\": false,\n \"skipTlsVerification\": false,\n \"timeout\": 30000,\n \"parsePDF\": true,\n \"jsonOptions\": {\n \"schema\": {},\n \"systemPrompt\": \"<string>\",\n \"prompt\": \"<string>\"\n },\n \"actions\": [\n {\n \"type\": \"wait\",\n \"milliseconds\": 2,\n \"selector\": \"#my-element\"\n }\n ],\n \"location\": {\n \"country\": \"US\",\n \"languages\": [\n \"en-US\"\n ]\n },\n \"removeBase64Images\": true,\n \"blockAds\": true,\n \"storeInCache\": true,\n \"formats\": [\n \"markdown\"\n ],\n \"changeTrackingOptions\": {\n \"modes\": [],\n \"schema\": {},\n \"prompt\": \"<string>\",\n \"tag\": null\n },\n \"zeroDataRetention\": false\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"id": "<string>",
"url": "<string>",
"invalidURLs": [
"<string>"
]
}{
"error": "Payment required to access this resource."
}{
"error": "Request rate limit exceeded. Please wait and try again later."
}{
"error": "An unexpected error occurred on the server."
}注意:此 API 的 v2 版本 现已推出,具备更高的批处理性能和可靠性。
授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
要爬取的 URL
Webhook 规范对象。
Show child attributes
Show child attributes
最大并发抓取数量。此参数用于为本次批量抓取设置并发上限。若未指定,则本次批量抓取将遵循你的团队并发限制。
如果在 urls 数组中指定了无效 URL,这些 URL 会被忽略。它们不会导致整个请求失败,而是会基于剩余的有效 URL 创建一个批量抓取任务,并在响应的 invalidURLs 字段中返回这些无效 URL。
仅返回页面的主体内容,不包括页眉、导航、页脚等。
需要包含在输出中的标签。
在输出结果中要排除的标签。
如果页面的缓存版本的生成时间距现在小于此值(毫秒),则返回该缓存版本;如果缓存版本早于此值,则会重新抓取页面。如果你不需要极其实时的数据,启用此选项可以将抓取速度最多提升 5 倍。默认值为 0,表示禁用缓存。
随请求发送的请求头。可用于携带 cookies、user-agent 等信息。
设置在获取内容前的延迟时间(毫秒),以便页面有足够时间加载完成。
若要模拟移动端抓取,请将其设置为 true。适用于测试响应式页面并获取移动端截图。
在发送请求时跳过 TLS 证书校验
请求超时时间(毫秒)
控制在爬取过程中如何处理 PDF 文件。为 true 时,会提取 PDF 内容并转换为 Markdown 格式,按页数计费(每页 1 个积分)。为 false 时,会返回以 base64 编码的 PDF 文件,统一按 1 个积分计费。
JSON 配置对象
Show child attributes
Show child attributes
在抓取页面内容前需要执行的 actions
- Wait
- Screenshot
- Click
- Write text
- Press a key
- Scroll
- Scrape
- Execute JavaScript
- Generate PDF
Show child attributes
Show child attributes
请求的地理位置设置。指定后,如果可用,将使用合适的代理服务器,并模拟相应的语言和时区设置。如果未指定,默认值为“US”。
Show child attributes
Show child attributes
从输出中移除所有 Base64 图片,以避免内容过于冗长。图片的替代文本(alt 文本)会保留在输出中,但其 URL 会被占位符替换。
启用广告拦截和 Cookie 弹窗屏蔽。
指定要使用的代理类型。
- basic:适用于抓取没有或仅有基础防爬机制网站的代理。速度快,通常足够好用。
- enhanced:适用于抓取具有高级防爬机制网站的增强型代理。速度较慢,但在某些网站上更可靠。每次请求最多消耗 5 个积分。
- auto:当使用 basic 代理抓取失败时,Firecrawl 会自动使用 enhanced 代理重试。如果使用 enhanced 重试成功,该次抓取将收取 5 个积分;如果首次使用 basic 即抓取成功,则只收取常规费用。
如果未指定代理类型,Firecrawl 将默认使用 basic。
basic, enhanced, auto 如果为 true,该页面将被存储到 Firecrawl 的索引和缓存中。若你的抓取活动可能涉及数据保护方面的问题,将其设置为 false 会更合适。使用某些与敏感抓取相关的参数(如 actions、headers)时,该参数会被强制设为 false。
输出中要包含的formats。
markdown, html, rawHtml, links, screenshot, screenshot@fullPage, json, changeTracking 用于 changeTracking 的选项(Beta)。仅当在 formats 中包含 'changeTracking' 时才适用。使用 changeTracking 时,还必须同时指定 'markdown' 格式。
Show child attributes
Show child attributes
若为 true,则此次批量抓取任务将不保留任何数据。要启用此功能,请联系 help@firecrawl.dev
curl --request POST \
--url https://api.firecrawl.dev/v1/batch/scrape \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"urls": [
"<string>"
],
"maxConcurrency": 123,
"ignoreInvalidURLs": false,
"onlyMainContent": true,
"includeTags": [
"<string>"
],
"excludeTags": [
"<string>"
],
"maxAge": 0,
"headers": {},
"waitFor": 0,
"mobile": false,
"skipTlsVerification": false,
"timeout": 30000,
"parsePDF": true,
"jsonOptions": {
"schema": {},
"systemPrompt": "<string>",
"prompt": "<string>"
},
"actions": [
{
"type": "wait",
"milliseconds": 2,
"selector": "#my-element"
}
],
"location": {
"country": "US",
"languages": [
"en-US"
]
},
"removeBase64Images": true,
"blockAds": true,
"storeInCache": true,
"formats": [
"markdown"
],
"changeTrackingOptions": {
"modes": [],
"schema": {},
"prompt": "<string>",
"tag": null
},
"zeroDataRetention": false
}
'import requests
url = "https://api.firecrawl.dev/v1/batch/scrape"
payload = {
"urls": ["<string>"],
"maxConcurrency": 123,
"ignoreInvalidURLs": False,
"onlyMainContent": True,
"includeTags": ["<string>"],
"excludeTags": ["<string>"],
"maxAge": 0,
"headers": {},
"waitFor": 0,
"mobile": False,
"skipTlsVerification": False,
"timeout": 30000,
"parsePDF": True,
"jsonOptions": {
"schema": {},
"systemPrompt": "<string>",
"prompt": "<string>"
},
"actions": [
{
"type": "wait",
"milliseconds": 2,
"selector": "#my-element"
}
],
"location": {
"country": "US",
"languages": ["en-US"]
},
"removeBase64Images": True,
"blockAds": True,
"storeInCache": True,
"formats": ["markdown"],
"changeTrackingOptions": {
"modes": [],
"schema": {},
"prompt": "<string>",
"tag": None
},
"zeroDataRetention": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
urls: ['<string>'],
maxConcurrency: 123,
ignoreInvalidURLs: false,
onlyMainContent: true,
includeTags: ['<string>'],
excludeTags: ['<string>'],
maxAge: 0,
headers: {},
waitFor: 0,
mobile: false,
skipTlsVerification: false,
timeout: 30000,
parsePDF: true,
jsonOptions: {schema: {}, systemPrompt: '<string>', prompt: '<string>'},
actions: [{type: 'wait', milliseconds: 2, selector: '#my-element'}],
location: {country: 'US', languages: ['en-US']},
removeBase64Images: true,
blockAds: true,
storeInCache: true,
formats: ['markdown'],
changeTrackingOptions: {modes: [], schema: {}, prompt: '<string>', tag: null},
zeroDataRetention: false
})
};
fetch('https://api.firecrawl.dev/v1/batch/scrape', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.firecrawl.dev/v1/batch/scrape",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'urls' => [
'<string>'
],
'maxConcurrency' => 123,
'ignoreInvalidURLs' => false,
'onlyMainContent' => true,
'includeTags' => [
'<string>'
],
'excludeTags' => [
'<string>'
],
'maxAge' => 0,
'headers' => [
],
'waitFor' => 0,
'mobile' => false,
'skipTlsVerification' => false,
'timeout' => 30000,
'parsePDF' => true,
'jsonOptions' => [
'schema' => [
],
'systemPrompt' => '<string>',
'prompt' => '<string>'
],
'actions' => [
[
'type' => 'wait',
'milliseconds' => 2,
'selector' => '#my-element'
]
],
'location' => [
'country' => 'US',
'languages' => [
'en-US'
]
],
'removeBase64Images' => true,
'blockAds' => true,
'storeInCache' => true,
'formats' => [
'markdown'
],
'changeTrackingOptions' => [
'modes' => [
],
'schema' => [
],
'prompt' => '<string>',
'tag' => null
],
'zeroDataRetention' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.firecrawl.dev/v1/batch/scrape"
payload := strings.NewReader("{\n \"urls\": [\n \"<string>\"\n ],\n \"maxConcurrency\": 123,\n \"ignoreInvalidURLs\": false,\n \"onlyMainContent\": true,\n \"includeTags\": [\n \"<string>\"\n ],\n \"excludeTags\": [\n \"<string>\"\n ],\n \"maxAge\": 0,\n \"headers\": {},\n \"waitFor\": 0,\n \"mobile\": false,\n \"skipTlsVerification\": false,\n \"timeout\": 30000,\n \"parsePDF\": true,\n \"jsonOptions\": {\n \"schema\": {},\n \"systemPrompt\": \"<string>\",\n \"prompt\": \"<string>\"\n },\n \"actions\": [\n {\n \"type\": \"wait\",\n \"milliseconds\": 2,\n \"selector\": \"#my-element\"\n }\n ],\n \"location\": {\n \"country\": \"US\",\n \"languages\": [\n \"en-US\"\n ]\n },\n \"removeBase64Images\": true,\n \"blockAds\": true,\n \"storeInCache\": true,\n \"formats\": [\n \"markdown\"\n ],\n \"changeTrackingOptions\": {\n \"modes\": [],\n \"schema\": {},\n \"prompt\": \"<string>\",\n \"tag\": null\n },\n \"zeroDataRetention\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.firecrawl.dev/v1/batch/scrape")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"urls\": [\n \"<string>\"\n ],\n \"maxConcurrency\": 123,\n \"ignoreInvalidURLs\": false,\n \"onlyMainContent\": true,\n \"includeTags\": [\n \"<string>\"\n ],\n \"excludeTags\": [\n \"<string>\"\n ],\n \"maxAge\": 0,\n \"headers\": {},\n \"waitFor\": 0,\n \"mobile\": false,\n \"skipTlsVerification\": false,\n \"timeout\": 30000,\n \"parsePDF\": true,\n \"jsonOptions\": {\n \"schema\": {},\n \"systemPrompt\": \"<string>\",\n \"prompt\": \"<string>\"\n },\n \"actions\": [\n {\n \"type\": \"wait\",\n \"milliseconds\": 2,\n \"selector\": \"#my-element\"\n }\n ],\n \"location\": {\n \"country\": \"US\",\n \"languages\": [\n \"en-US\"\n ]\n },\n \"removeBase64Images\": true,\n \"blockAds\": true,\n \"storeInCache\": true,\n \"formats\": [\n \"markdown\"\n ],\n \"changeTrackingOptions\": {\n \"modes\": [],\n \"schema\": {},\n \"prompt\": \"<string>\",\n \"tag\": null\n },\n \"zeroDataRetention\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firecrawl.dev/v1/batch/scrape")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"urls\": [\n \"<string>\"\n ],\n \"maxConcurrency\": 123,\n \"ignoreInvalidURLs\": false,\n \"onlyMainContent\": true,\n \"includeTags\": [\n \"<string>\"\n ],\n \"excludeTags\": [\n \"<string>\"\n ],\n \"maxAge\": 0,\n \"headers\": {},\n \"waitFor\": 0,\n \"mobile\": false,\n \"skipTlsVerification\": false,\n \"timeout\": 30000,\n \"parsePDF\": true,\n \"jsonOptions\": {\n \"schema\": {},\n \"systemPrompt\": \"<string>\",\n \"prompt\": \"<string>\"\n },\n \"actions\": [\n {\n \"type\": \"wait\",\n \"milliseconds\": 2,\n \"selector\": \"#my-element\"\n }\n ],\n \"location\": {\n \"country\": \"US\",\n \"languages\": [\n \"en-US\"\n ]\n },\n \"removeBase64Images\": true,\n \"blockAds\": true,\n \"storeInCache\": true,\n \"formats\": [\n \"markdown\"\n ],\n \"changeTrackingOptions\": {\n \"modes\": [],\n \"schema\": {},\n \"prompt\": \"<string>\",\n \"tag\": null\n },\n \"zeroDataRetention\": false\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"id": "<string>",
"url": "<string>",
"invalidURLs": [
"<string>"
]
}{
"error": "Payment required to access this resource."
}{
"error": "Request rate limit exceeded. Please wait and try again later."
}{
"error": "An unexpected error occurred on the server."
}