Scrape
curl --request POST \
--url https://api.firecrawl.dev/v2/scrape \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"formats": [
"markdown"
],
"onlyMainContent": true,
"includeTags": [
"<string>"
],
"excludeTags": [
"<string>"
],
"maxAge": 172800000,
"headers": {},
"waitFor": 0,
"mobile": false,
"skipTlsVerification": true,
"timeout": 30000,
"parsers": [
"pdf"
],
"actions": [
{
"type": "wait",
"milliseconds": 2
}
],
"location": {
"country": "US",
"languages": [
"en-US"
]
},
"removeBase64Images": true,
"blockAds": true,
"proxy": "auto",
"storeInCache": true,
"zeroDataRetention": false
}
'import requests
url = "https://api.firecrawl.dev/v2/scrape"
payload = {
"url": "<string>",
"formats": ["markdown"],
"onlyMainContent": True,
"includeTags": ["<string>"],
"excludeTags": ["<string>"],
"maxAge": 172800000,
"headers": {},
"waitFor": 0,
"mobile": False,
"skipTlsVerification": True,
"timeout": 30000,
"parsers": ["pdf"],
"actions": [
{
"type": "wait",
"milliseconds": 2
}
],
"location": {
"country": "US",
"languages": ["en-US"]
},
"removeBase64Images": True,
"blockAds": True,
"proxy": "auto",
"storeInCache": True,
"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({
url: '<string>',
formats: ['markdown'],
onlyMainContent: true,
includeTags: ['<string>'],
excludeTags: ['<string>'],
maxAge: 172800000,
headers: {},
waitFor: 0,
mobile: false,
skipTlsVerification: true,
timeout: 30000,
parsers: ['pdf'],
actions: [{type: 'wait', milliseconds: 2}],
location: {country: 'US', languages: ['en-US']},
removeBase64Images: true,
blockAds: true,
proxy: 'auto',
storeInCache: true,
zeroDataRetention: false
})
};
fetch('https://api.firecrawl.dev/v2/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/v2/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([
'url' => '<string>',
'formats' => [
'markdown'
],
'onlyMainContent' => true,
'includeTags' => [
'<string>'
],
'excludeTags' => [
'<string>'
],
'maxAge' => 172800000,
'headers' => [
],
'waitFor' => 0,
'mobile' => false,
'skipTlsVerification' => true,
'timeout' => 30000,
'parsers' => [
'pdf'
],
'actions' => [
[
'type' => 'wait',
'milliseconds' => 2
]
],
'location' => [
'country' => 'US',
'languages' => [
'en-US'
]
],
'removeBase64Images' => true,
'blockAds' => true,
'proxy' => 'auto',
'storeInCache' => true,
'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/v2/scrape"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"formats\": [\n \"markdown\"\n ],\n \"onlyMainContent\": true,\n \"includeTags\": [\n \"<string>\"\n ],\n \"excludeTags\": [\n \"<string>\"\n ],\n \"maxAge\": 172800000,\n \"headers\": {},\n \"waitFor\": 0,\n \"mobile\": false,\n \"skipTlsVerification\": true,\n \"timeout\": 30000,\n \"parsers\": [\n \"pdf\"\n ],\n \"actions\": [\n {\n \"type\": \"wait\",\n \"milliseconds\": 2\n }\n ],\n \"location\": {\n \"country\": \"US\",\n \"languages\": [\n \"en-US\"\n ]\n },\n \"removeBase64Images\": true,\n \"blockAds\": true,\n \"proxy\": \"auto\",\n \"storeInCache\": true,\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/v2/scrape")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"formats\": [\n \"markdown\"\n ],\n \"onlyMainContent\": true,\n \"includeTags\": [\n \"<string>\"\n ],\n \"excludeTags\": [\n \"<string>\"\n ],\n \"maxAge\": 172800000,\n \"headers\": {},\n \"waitFor\": 0,\n \"mobile\": false,\n \"skipTlsVerification\": true,\n \"timeout\": 30000,\n \"parsers\": [\n \"pdf\"\n ],\n \"actions\": [\n {\n \"type\": \"wait\",\n \"milliseconds\": 2\n }\n ],\n \"location\": {\n \"country\": \"US\",\n \"languages\": [\n \"en-US\"\n ]\n },\n \"removeBase64Images\": true,\n \"blockAds\": true,\n \"proxy\": \"auto\",\n \"storeInCache\": true,\n \"zeroDataRetention\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firecrawl.dev/v2/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 \"url\": \"<string>\",\n \"formats\": [\n \"markdown\"\n ],\n \"onlyMainContent\": true,\n \"includeTags\": [\n \"<string>\"\n ],\n \"excludeTags\": [\n \"<string>\"\n ],\n \"maxAge\": 172800000,\n \"headers\": {},\n \"waitFor\": 0,\n \"mobile\": false,\n \"skipTlsVerification\": true,\n \"timeout\": 30000,\n \"parsers\": [\n \"pdf\"\n ],\n \"actions\": [\n {\n \"type\": \"wait\",\n \"milliseconds\": 2\n }\n ],\n \"location\": {\n \"country\": \"US\",\n \"languages\": [\n \"en-US\"\n ]\n },\n \"removeBase64Images\": true,\n \"blockAds\": true,\n \"proxy\": \"auto\",\n \"storeInCache\": true,\n \"zeroDataRetention\": false\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"markdown": "<string>",
"summary": "<string>",
"html": "<string>",
"rawHtml": "<string>",
"screenshot": "<string>",
"links": [
"<string>"
],
"actions": {
"screenshots": [
"<string>"
],
"scrapes": [
{
"url": "<string>",
"html": "<string>"
}
],
"javascriptReturns": [
{
"type": "<string>",
"value": "<unknown>"
}
],
"pdfs": [
"<string>"
]
},
"metadata": {
"title": "<string>",
"description": "<string>",
"language": "<string>",
"sourceURL": "<string>",
"url": "<string>",
"keywords": "<string>",
"ogLocaleAlternate": [
"<string>"
],
"<any other metadata> ": "<string>",
"statusCode": 123,
"error": "<string>"
},
"warning": "<string>",
"changeTracking": {
"previousScrapeAt": "2023-11-07T05:31:56Z",
"diff": "<string>",
"json": {}
},
"branding": {
"logo": "<string>",
"colors": {
"primary": "<string>",
"secondary": "<string>",
"accent": "<string>",
"background": "<string>",
"textPrimary": "<string>",
"textSecondary": "<string>",
"link": "<string>",
"success": "<string>",
"warning": "<string>",
"error": "<string>"
},
"fonts": [
{
"family": "<string>"
}
],
"typography": {
"fontFamilies": {
"primary": "<string>",
"heading": "<string>",
"code": "<string>"
},
"fontSizes": {
"h1": "<string>",
"h2": "<string>",
"h3": "<string>",
"body": "<string>"
},
"fontWeights": {
"light": 123,
"regular": 123,
"medium": 123,
"bold": 123
},
"lineHeights": {
"heading": "<string>",
"body": "<string>"
}
},
"spacing": {
"baseUnit": 123,
"borderRadius": "<string>",
"padding": {},
"margins": {}
},
"components": {
"buttonPrimary": {
"background": "<string>",
"textColor": "<string>",
"borderRadius": "<string>"
},
"buttonSecondary": {
"background": "<string>",
"textColor": "<string>",
"borderColor": "<string>",
"borderRadius": "<string>"
},
"input": {}
},
"icons": {},
"images": {
"logo": "<string>",
"favicon": "<string>",
"ogImage": "<string>"
},
"animations": {},
"layout": {},
"personality": {}
}
}
}{
"error": "Payment required to access this resource."
}{
"error": "Request rate limit exceeded. Please wait and try again later."
}{
"success": false,
"code": "UNKNOWN_ERROR",
"error": "An unexpected error occurred on the server."
}浏览器 actions
actions 参数执行浏览器交互操作。这使你可以:
- 等待元素加载
- 点击按钮或链接
- 填写表单字段
- 按下按键
- 滚动页面
- 截取页面截图
- 执行自定义 JavaScript
- 生成 PDF
wait、click、write、press、scroll、screenshot、scrape、executeJavascript 和 pdf。有关包含示例的详细文档,请参阅 高级抓取指南。授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
要爬取的 URL
要在响应中包含的输出 formats。你可以指定一个或多个 formats,既可以使用字符串(例如:'markdown'),也可以使用带有其他选项的对象(例如:{ type: 'json', schema: {...} })。某些 formats 需要配置特定选项。示例:['markdown', { type: 'json', schema: {...} }]。
- Markdown
- Summary
- HTML
- Raw HTML
- Links
- Images
- Screenshot
- JSON
- Change Tracking
- Branding
Show child attributes
Show child attributes
仅返回页面的主要内容,不包含 header、nav、footer 等元素。
在输出中要包含的标签。
在输出中需要排除的标签。
如果页面的缓存版本的生成时间距今少于该毫秒数,则返回该缓存页面;如果缓存版本距今超过该时间,则会重新抓取页面。若你不需要特别新的数据,启用此选项可将抓取速度提升至 5 倍。默认值为 2 天。
随请求发送的请求头。可用于传递 cookies、User-Agent 等信息。
指定在抓取内容前的延迟时间(毫秒),以便页面有足够时间完成加载。该等待时间是在 Firecrawl 的智能等待功能基础上的额外等待。
若要模拟在移动设备上进行抓取,请将其设置为 true。适用于测试响应式页面并获取移动端截图。
在发起请求时跳过 TLS 证书验证。
请求超时时间(毫秒)。默认 30000(30 秒),最大 300000(300 秒)。
x <= 300000用于控制在抓取过程中如何处理文件。包含 "pdf" 时(默认),会提取 PDF 内容并转换为 Markdown 格式,计费基于页数(每页 1 点数)。当传入空数组时,会以 base64 编码返回整个 PDF 文件,并对整份 PDF 按单一费率收取 1 点数。
Show child attributes
Show child attributes
在抓取页面内容之前需要执行的页面 actions
- Wait by Duration
- Wait for Element
- 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 一次就成功,则只按常规定价计费。
basic, enhanced, auto 如果为 true,该页面会存储到 Firecrawl 的索引和缓存中。如果你的抓取操作可能涉及数据保护方面的顾虑,将其设置为 false 会很有用。使用某些与敏感抓取相关的参数(例如 actions、headers)时,会被强制将此参数设为 false。
如果为 true,则本次抓取将不保留任何数据。要启用此功能,请联系 help@firecrawl.dev
curl --request POST \
--url https://api.firecrawl.dev/v2/scrape \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"formats": [
"markdown"
],
"onlyMainContent": true,
"includeTags": [
"<string>"
],
"excludeTags": [
"<string>"
],
"maxAge": 172800000,
"headers": {},
"waitFor": 0,
"mobile": false,
"skipTlsVerification": true,
"timeout": 30000,
"parsers": [
"pdf"
],
"actions": [
{
"type": "wait",
"milliseconds": 2
}
],
"location": {
"country": "US",
"languages": [
"en-US"
]
},
"removeBase64Images": true,
"blockAds": true,
"proxy": "auto",
"storeInCache": true,
"zeroDataRetention": false
}
'import requests
url = "https://api.firecrawl.dev/v2/scrape"
payload = {
"url": "<string>",
"formats": ["markdown"],
"onlyMainContent": True,
"includeTags": ["<string>"],
"excludeTags": ["<string>"],
"maxAge": 172800000,
"headers": {},
"waitFor": 0,
"mobile": False,
"skipTlsVerification": True,
"timeout": 30000,
"parsers": ["pdf"],
"actions": [
{
"type": "wait",
"milliseconds": 2
}
],
"location": {
"country": "US",
"languages": ["en-US"]
},
"removeBase64Images": True,
"blockAds": True,
"proxy": "auto",
"storeInCache": True,
"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({
url: '<string>',
formats: ['markdown'],
onlyMainContent: true,
includeTags: ['<string>'],
excludeTags: ['<string>'],
maxAge: 172800000,
headers: {},
waitFor: 0,
mobile: false,
skipTlsVerification: true,
timeout: 30000,
parsers: ['pdf'],
actions: [{type: 'wait', milliseconds: 2}],
location: {country: 'US', languages: ['en-US']},
removeBase64Images: true,
blockAds: true,
proxy: 'auto',
storeInCache: true,
zeroDataRetention: false
})
};
fetch('https://api.firecrawl.dev/v2/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/v2/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([
'url' => '<string>',
'formats' => [
'markdown'
],
'onlyMainContent' => true,
'includeTags' => [
'<string>'
],
'excludeTags' => [
'<string>'
],
'maxAge' => 172800000,
'headers' => [
],
'waitFor' => 0,
'mobile' => false,
'skipTlsVerification' => true,
'timeout' => 30000,
'parsers' => [
'pdf'
],
'actions' => [
[
'type' => 'wait',
'milliseconds' => 2
]
],
'location' => [
'country' => 'US',
'languages' => [
'en-US'
]
],
'removeBase64Images' => true,
'blockAds' => true,
'proxy' => 'auto',
'storeInCache' => true,
'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/v2/scrape"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"formats\": [\n \"markdown\"\n ],\n \"onlyMainContent\": true,\n \"includeTags\": [\n \"<string>\"\n ],\n \"excludeTags\": [\n \"<string>\"\n ],\n \"maxAge\": 172800000,\n \"headers\": {},\n \"waitFor\": 0,\n \"mobile\": false,\n \"skipTlsVerification\": true,\n \"timeout\": 30000,\n \"parsers\": [\n \"pdf\"\n ],\n \"actions\": [\n {\n \"type\": \"wait\",\n \"milliseconds\": 2\n }\n ],\n \"location\": {\n \"country\": \"US\",\n \"languages\": [\n \"en-US\"\n ]\n },\n \"removeBase64Images\": true,\n \"blockAds\": true,\n \"proxy\": \"auto\",\n \"storeInCache\": true,\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/v2/scrape")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"formats\": [\n \"markdown\"\n ],\n \"onlyMainContent\": true,\n \"includeTags\": [\n \"<string>\"\n ],\n \"excludeTags\": [\n \"<string>\"\n ],\n \"maxAge\": 172800000,\n \"headers\": {},\n \"waitFor\": 0,\n \"mobile\": false,\n \"skipTlsVerification\": true,\n \"timeout\": 30000,\n \"parsers\": [\n \"pdf\"\n ],\n \"actions\": [\n {\n \"type\": \"wait\",\n \"milliseconds\": 2\n }\n ],\n \"location\": {\n \"country\": \"US\",\n \"languages\": [\n \"en-US\"\n ]\n },\n \"removeBase64Images\": true,\n \"blockAds\": true,\n \"proxy\": \"auto\",\n \"storeInCache\": true,\n \"zeroDataRetention\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firecrawl.dev/v2/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 \"url\": \"<string>\",\n \"formats\": [\n \"markdown\"\n ],\n \"onlyMainContent\": true,\n \"includeTags\": [\n \"<string>\"\n ],\n \"excludeTags\": [\n \"<string>\"\n ],\n \"maxAge\": 172800000,\n \"headers\": {},\n \"waitFor\": 0,\n \"mobile\": false,\n \"skipTlsVerification\": true,\n \"timeout\": 30000,\n \"parsers\": [\n \"pdf\"\n ],\n \"actions\": [\n {\n \"type\": \"wait\",\n \"milliseconds\": 2\n }\n ],\n \"location\": {\n \"country\": \"US\",\n \"languages\": [\n \"en-US\"\n ]\n },\n \"removeBase64Images\": true,\n \"blockAds\": true,\n \"proxy\": \"auto\",\n \"storeInCache\": true,\n \"zeroDataRetention\": false\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"markdown": "<string>",
"summary": "<string>",
"html": "<string>",
"rawHtml": "<string>",
"screenshot": "<string>",
"links": [
"<string>"
],
"actions": {
"screenshots": [
"<string>"
],
"scrapes": [
{
"url": "<string>",
"html": "<string>"
}
],
"javascriptReturns": [
{
"type": "<string>",
"value": "<unknown>"
}
],
"pdfs": [
"<string>"
]
},
"metadata": {
"title": "<string>",
"description": "<string>",
"language": "<string>",
"sourceURL": "<string>",
"url": "<string>",
"keywords": "<string>",
"ogLocaleAlternate": [
"<string>"
],
"<any other metadata> ": "<string>",
"statusCode": 123,
"error": "<string>"
},
"warning": "<string>",
"changeTracking": {
"previousScrapeAt": "2023-11-07T05:31:56Z",
"diff": "<string>",
"json": {}
},
"branding": {
"logo": "<string>",
"colors": {
"primary": "<string>",
"secondary": "<string>",
"accent": "<string>",
"background": "<string>",
"textPrimary": "<string>",
"textSecondary": "<string>",
"link": "<string>",
"success": "<string>",
"warning": "<string>",
"error": "<string>"
},
"fonts": [
{
"family": "<string>"
}
],
"typography": {
"fontFamilies": {
"primary": "<string>",
"heading": "<string>",
"code": "<string>"
},
"fontSizes": {
"h1": "<string>",
"h2": "<string>",
"h3": "<string>",
"body": "<string>"
},
"fontWeights": {
"light": 123,
"regular": 123,
"medium": 123,
"bold": 123
},
"lineHeights": {
"heading": "<string>",
"body": "<string>"
}
},
"spacing": {
"baseUnit": 123,
"borderRadius": "<string>",
"padding": {},
"margins": {}
},
"components": {
"buttonPrimary": {
"background": "<string>",
"textColor": "<string>",
"borderRadius": "<string>"
},
"buttonSecondary": {
"background": "<string>",
"textColor": "<string>",
"borderColor": "<string>",
"borderRadius": "<string>"
},
"input": {}
},
"icons": {},
"images": {
"logo": "<string>",
"favicon": "<string>",
"ogImage": "<string>"
},
"animations": {},
"layout": {},
"personality": {}
}
}
}{
"error": "Payment required to access this resource."
}{
"error": "Request rate limit exceeded. Please wait and try again later."
}{
"success": false,
"code": "UNKNOWN_ERROR",
"error": "An unexpected error occurred on the server."
}