スクレイプ
curl --request POST \
--url https://api.firecrawl.dev/v1/scrape \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"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/scrape"
payload = {
"url": "<string>",
"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({
url: '<string>',
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/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/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>',
'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/scrape"
payload := strings.NewReader("{\n \"url\": \"<string>\",\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/scrape")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\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/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 \"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,
"data": {
"markdown": "<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>",
"keywords": "<string>",
"ogLocaleAlternate": [
"<string>"
],
"<any other metadata> ": "<string>",
"statusCode": 123,
"error": "<string>"
},
"llm_extraction": {},
"warning": "<string>",
"changeTracking": {
"previousScrapeAt": "2023-11-07T05:31:56Z",
"diff": "<string>",
"json": {}
}
}
}{
"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
ヘッダー、ナビゲーション、フッターなどを除き、ページのメインコンテンツのみを返します。
出力に含めるタグ。
出力結果から除外するタグ。
ページのキャッシュが、このミリ秒数以内に生成されたものであれば、そのキャッシュされたバージョンを返します。キャッシュされたページがこの値より古い場合は、ページをスクレイピングします。極めて最新のデータが不要な場合、これを有効にすることでスクレイピングを最大 500% 高速化できます。デフォルトは 0 で、この場合キャッシュは無効になります。
リクエストに付与して送信するヘッダー。Cookie や User-Agent などを送るために使用できます。
コンテンツを取得する前に待機する時間(ディレイ)をミリ秒単位で指定します。これにより、ページが十分に読み込まれるまでの時間を確保できます。
モバイル端末からのスクレイピングを模擬したい場合は true に設定してください。レスポンシブページのテストやモバイル画面のスクリーンショット取得に便利です。
リクエスト時に TLS 証明書の検証をスキップする
リクエストのタイムアウト(ミリ秒)
スクレイピング中のPDFファイルの処理方法を制御します。true の場合、PDFのコンテンツを抽出してMarkdown形式に変換し、課金はページ数に基づきます(1ページあたり1クレジット)。false の場合、PDFファイルはbase64エンコードされたデータとして返され、合計1クレジットの定額課金となります。
JSON オプションオブジェクト
Show child attributes
Show child attributes
ページからコンテンツを取得する前に実行するアクション
- 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 はプレースホルダーに置き換えられます。
広告とクッキーポップアップのブロックを有効にします。
使用するプロキシの種類を指定します。
- basic: ボット対策がない、または基本的なボット対策のみが導入されているサイト向けのプロキシです。高速で、ほとんどの場合はこれで十分です。
- enhanced: 高度なボット対策が導入されているサイト向けの強化プロキシです。速度は遅くなりますが、特定のサイトではより信頼性があります。1 リクエストあたり最大 5 クレジット消費します。
- auto: basic プロキシでのスクレイピングが失敗した場合に、Firecrawl が自動的に enhanced プロキシで再試行します。enhanced での再試行が成功した場合、そのスクレイピングには 5 クレジットが請求されます。最初の basic での試行が成功した場合は、通常どおりのコストのみが請求されます。
プロキシを指定しない場合、Firecrawl はデフォルトで basic を使用します。
basic, enhanced, auto true の場合、そのページは Firecrawl のインデックスおよびキャッシュに保存されます。スクレイピング内容がデータ保護上の懸念を伴う可能性がある場合は、これを false に設定するのが有効です。機密性の高いスクレイピングに関連する一部のパラメータ(アクションやヘッダーなど)を使用すると、このパラメータは強制的に false に設定されます。
出力に含めるフォーマット。
markdown, html, rawHtml, links, screenshot, screenshot@fullPage, json, changeTracking 変更追跡用のオプション(ベータ版)。changeTracking がフォーマットに含まれている場合にのみ有効です。変更追跡を使用する際は、markdown フォーマットも指定する必要があります。
Show child attributes
Show child attributes
true の場合、このスクレイプではデータを一切保持しないゼロデータ保持モードが有効になります。この機能を有効にするには、help@firecrawl.dev までご連絡ください。
curl --request POST \
--url https://api.firecrawl.dev/v1/scrape \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"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/scrape"
payload = {
"url": "<string>",
"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({
url: '<string>',
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/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/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>',
'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/scrape"
payload := strings.NewReader("{\n \"url\": \"<string>\",\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/scrape")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\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/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 \"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,
"data": {
"markdown": "<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>",
"keywords": "<string>",
"ogLocaleAlternate": [
"<string>"
],
"<any other metadata> ": "<string>",
"statusCode": 123,
"error": "<string>"
},
"llm_extraction": {},
"warning": "<string>",
"changeTracking": {
"previousScrapeAt": "2023-11-07T05:31:56Z",
"diff": "<string>",
"json": {}
}
}
}{
"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."
}