Webスクレイピング API
同期スクレイピング
scrape エンドポイントはブラウザセッションを実行し、JavaScript を実行して、1 回の同期リクエストでレンダリング済み HTML を返します。
POST
/
v1
/
scrape
同期スクレイピング
curl --request POST \
--url https://scrape.cleariflow.com/v1/scrape \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"api_key": "<string>",
"session_id": "<string>",
"fingerprint": "<string>",
"render": {},
"render.wait_until": "<string>",
"render.timeout_ms": 123,
"render.post_load_wait_ms": 123,
"render.ignore_https_errors": true,
"resources": {},
"resources.block": [
{}
],
"actions": [
{}
],
"actions[].type": "<string>",
"actions[].selector": "<string>",
"actions[].text": "<string>",
"actions[].to": "<string>",
"actions[].wait_ms": 123,
"actions[].timeout_ms": 123,
"cookies": [
{}
]
}
'import requests
url = "https://scrape.cleariflow.com/v1/scrape"
payload = {
"url": "<string>",
"api_key": "<string>",
"session_id": "<string>",
"fingerprint": "<string>",
"render": {},
"render.wait_until": "<string>",
"render.timeout_ms": 123,
"render.post_load_wait_ms": 123,
"render.ignore_https_errors": True,
"resources": {},
"resources.block": [{}],
"actions": [{}],
"actions[].type": "<string>",
"actions[].selector": "<string>",
"actions[].text": "<string>",
"actions[].to": "<string>",
"actions[].wait_ms": 123,
"actions[].timeout_ms": 123,
"cookies": [{}]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
url: '<string>',
api_key: '<string>',
session_id: '<string>',
fingerprint: '<string>',
render: {},
'render.wait_until': '<string>',
'render.timeout_ms': 123,
'render.post_load_wait_ms': 123,
'render.ignore_https_errors': true,
resources: {},
'resources.block': [{}],
actions: [{}],
'actions[].type': '<string>',
'actions[].selector': '<string>',
'actions[].text': '<string>',
'actions[].to': '<string>',
'actions[].wait_ms': 123,
'actions[].timeout_ms': 123,
cookies: [{}]
})
};
fetch('https://scrape.cleariflow.com/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://scrape.cleariflow.com/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>',
'api_key' => '<string>',
'session_id' => '<string>',
'fingerprint' => '<string>',
'render' => [
],
'render.wait_until' => '<string>',
'render.timeout_ms' => 123,
'render.post_load_wait_ms' => 123,
'render.ignore_https_errors' => true,
'resources' => [
],
'resources.block' => [
[
]
],
'actions' => [
[
]
],
'actions[].type' => '<string>',
'actions[].selector' => '<string>',
'actions[].text' => '<string>',
'actions[].to' => '<string>',
'actions[].wait_ms' => 123,
'actions[].timeout_ms' => 123,
'cookies' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"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://scrape.cleariflow.com/v1/scrape"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"api_key\": \"<string>\",\n \"session_id\": \"<string>\",\n \"fingerprint\": \"<string>\",\n \"render\": {},\n \"render.wait_until\": \"<string>\",\n \"render.timeout_ms\": 123,\n \"render.post_load_wait_ms\": 123,\n \"render.ignore_https_errors\": true,\n \"resources\": {},\n \"resources.block\": [\n {}\n ],\n \"actions\": [\n {}\n ],\n \"actions[].type\": \"<string>\",\n \"actions[].selector\": \"<string>\",\n \"actions[].text\": \"<string>\",\n \"actions[].to\": \"<string>\",\n \"actions[].wait_ms\": 123,\n \"actions[].timeout_ms\": 123,\n \"cookies\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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://scrape.cleariflow.com/v1/scrape")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"api_key\": \"<string>\",\n \"session_id\": \"<string>\",\n \"fingerprint\": \"<string>\",\n \"render\": {},\n \"render.wait_until\": \"<string>\",\n \"render.timeout_ms\": 123,\n \"render.post_load_wait_ms\": 123,\n \"render.ignore_https_errors\": true,\n \"resources\": {},\n \"resources.block\": [\n {}\n ],\n \"actions\": [\n {}\n ],\n \"actions[].type\": \"<string>\",\n \"actions[].selector\": \"<string>\",\n \"actions[].text\": \"<string>\",\n \"actions[].to\": \"<string>\",\n \"actions[].wait_ms\": 123,\n \"actions[].timeout_ms\": 123,\n \"cookies\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://scrape.cleariflow.com/v1/scrape")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"api_key\": \"<string>\",\n \"session_id\": \"<string>\",\n \"fingerprint\": \"<string>\",\n \"render\": {},\n \"render.wait_until\": \"<string>\",\n \"render.timeout_ms\": 123,\n \"render.post_load_wait_ms\": 123,\n \"render.ignore_https_errors\": true,\n \"resources\": {},\n \"resources.block\": [\n {}\n ],\n \"actions\": [\n {}\n ],\n \"actions[].type\": \"<string>\",\n \"actions[].selector\": \"<string>\",\n \"actions[].text\": \"<string>\",\n \"actions[].to\": \"<string>\",\n \"actions[].wait_ms\": 123,\n \"actions[].timeout_ms\": 123,\n \"cookies\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"html": "<!DOCTYPE html><html>...</html>",
"meta": {
"elapsed_ms": 4521
}
}
はじめに
ベース URL
https://scrape.cleariflow.com/v1/scrape
リクエスト例
curl -X POST 'https://scrape.cleariflow.com/v1/scrape' \
-H 'Content-Type: application/json' \
-d '{
"api_key": "YOUR_UNIQUE_API_KEY",
"url": "https://example.com",
"render": {
"wait_until": "networkidle",
"timeout_ms": 60000
}
}'
{
"ok": true,
"html": "<!DOCTYPE html><html>...</html>",
"meta": {
"elapsed_ms": 4521
}
}
レンダリングオプション
render オブジェクトは HTML 取得前のページ読み込み方法を制御します。すべてのフィールドは任意で、省略時はサーバーのデフォルト値が適用されます。
"render": {
"wait_until": "networkidle",
"timeout_ms": 60000,
"post_load_wait_ms": 2000,
"ignore_https_errors": false
}
| フィールド | 型 | デフォルト | 説明 |
|---|---|---|---|
wait_until | String | domcontentloaded | ナビゲーション完了とみなすタイミング。高速な結果には domcontentloaded、初期 HTML 後に XHR/fetch でデータを読み込むページには networkidle。 |
timeout_ms | Integer | 60000 | ページ読み込みの最大待機時間(ミリ秒)。超過するとリクエストは失敗します。 |
post_load_wait_ms | Integer | 0 | wait_until 後、HTML 取得前の追加待機時間(ミリ秒)。アニメーション、lazy-load ウィジェット、networkidle 後のクライアント側レンダリングに有用。 |
ignore_https_errors | Boolean | false | true の場合、対象ページの TLS 証明書エラーを無視します。 |
curl -X POST 'https://scrape.cleariflow.com/v1/scrape' \
-H 'Content-Type: application/json' \
-d '{
"api_key": "YOUR_UNIQUE_API_KEY",
"url": "https://quotes.toscrape.com/js/",
"render": {
"wait_until": "networkidle",
"timeout_ms": 60000,
"post_load_wait_ms": 1500,
"ignore_https_errors": false
}
}'
リソースオプション
resources オブジェクトはスクレイピング中にブラウザが読み込むアセット種別を制御します。HTML のテキストと構造だけが必要な場合、重いリソースをブロックするとリクエストが高速化されます。
"resources": {
"block": ["images", "fonts", "media"]
}
| 値 | ブロック対象 |
|---|---|
images | 画像(<img>、CSS 背景、画像として読み込まれる SVG アイコン) |
fonts | Web フォント |
media | 動画・音声ストリーム |
resources を省略した場合、デプロイメントでサーバー側デフォルトが設定されていない限り、リソース種別はブロックされません。
例 — 画像とフォントをスキップして高速化:
curl -X POST 'https://scrape.cleariflow.com/v1/scrape' \
-H 'Content-Type: application/json' \
-d '{
"api_key": "YOUR_UNIQUE_API_KEY",
"url": "https://quotes.toscrape.com/",
"resources": {
"block": ["images", "fonts"]
}
}'
リクエストパラメータ
String
必須
スクレイピング対象 URL。公開 HTTP または HTTPS URL である必要があります。localhost およびプライベート IP へのリクエストは SSRF 保護によりブロックされます。
String
必須
固有の API キー。
String
複数のスクレイピングリクエスト間でブラウザ状態(Cookie、ローカルストレージ)を再利用するためのオプションのセッション ID。
String
ブラウザフィンガープリントプリセット。対応値:
desktop_en_us、desktop_ru_ru、mobile_en_us。Object
ブラウザセッションのレンダリングオプション。
String
ナビゲーション完了とみなすタイミング。値:
domcontentloaded、networkidle。デフォルト: domcontentloaded。Integer
ページ読み込み待機の最大時間(ミリ秒)。デフォルト: 60000。
Integer
ページ読み込み後、コンテンツ取得前の追加待機時間(ミリ秒)。
Boolean
true の場合、ターゲットページの TLS 証明書エラーを無視します。Object
リソース読み込みの制御。
Array
ブロックするリソースタイプ。対応値:
images、fonts、media。Array
コンテンツ取得前に実行するブラウザアクションの順序付きリスト。各アクションは
type フィールドを持つオブジェクトです。String
必須
アクションタイプ。対応値:
wait、wait_for、click、type、scroll。String
wait_for、click、type アクション用の CSS セレクタ。String
type アクションで入力するテキスト。String
scroll アクションのスクロール先(例: bottom)。Integer
wait アクションの待機時間(ミリ秒)。Integer
wait_for アクションのタイムアウト(ミリ秒)。Array
ナビゲーション前に注入する Cookie。各 Cookie オブジェクトには
name と value が必要。オプション: domain、path。レスポンスパラメータ
API レスポンスは汎用的で軽量な JSON 形式で返されます。Boolean
スクレイピングが正常に完了したかどうか。
String
レンダリング済みページ HTML。
Object
最終 URL、HTTP ステータスコード、処理時間などのスクレイピングメタデータ。
Object
ok が false の場合のエラー詳細。⌘I
同期スクレイピング
curl --request POST \
--url https://scrape.cleariflow.com/v1/scrape \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"api_key": "<string>",
"session_id": "<string>",
"fingerprint": "<string>",
"render": {},
"render.wait_until": "<string>",
"render.timeout_ms": 123,
"render.post_load_wait_ms": 123,
"render.ignore_https_errors": true,
"resources": {},
"resources.block": [
{}
],
"actions": [
{}
],
"actions[].type": "<string>",
"actions[].selector": "<string>",
"actions[].text": "<string>",
"actions[].to": "<string>",
"actions[].wait_ms": 123,
"actions[].timeout_ms": 123,
"cookies": [
{}
]
}
'import requests
url = "https://scrape.cleariflow.com/v1/scrape"
payload = {
"url": "<string>",
"api_key": "<string>",
"session_id": "<string>",
"fingerprint": "<string>",
"render": {},
"render.wait_until": "<string>",
"render.timeout_ms": 123,
"render.post_load_wait_ms": 123,
"render.ignore_https_errors": True,
"resources": {},
"resources.block": [{}],
"actions": [{}],
"actions[].type": "<string>",
"actions[].selector": "<string>",
"actions[].text": "<string>",
"actions[].to": "<string>",
"actions[].wait_ms": 123,
"actions[].timeout_ms": 123,
"cookies": [{}]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
url: '<string>',
api_key: '<string>',
session_id: '<string>',
fingerprint: '<string>',
render: {},
'render.wait_until': '<string>',
'render.timeout_ms': 123,
'render.post_load_wait_ms': 123,
'render.ignore_https_errors': true,
resources: {},
'resources.block': [{}],
actions: [{}],
'actions[].type': '<string>',
'actions[].selector': '<string>',
'actions[].text': '<string>',
'actions[].to': '<string>',
'actions[].wait_ms': 123,
'actions[].timeout_ms': 123,
cookies: [{}]
})
};
fetch('https://scrape.cleariflow.com/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://scrape.cleariflow.com/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>',
'api_key' => '<string>',
'session_id' => '<string>',
'fingerprint' => '<string>',
'render' => [
],
'render.wait_until' => '<string>',
'render.timeout_ms' => 123,
'render.post_load_wait_ms' => 123,
'render.ignore_https_errors' => true,
'resources' => [
],
'resources.block' => [
[
]
],
'actions' => [
[
]
],
'actions[].type' => '<string>',
'actions[].selector' => '<string>',
'actions[].text' => '<string>',
'actions[].to' => '<string>',
'actions[].wait_ms' => 123,
'actions[].timeout_ms' => 123,
'cookies' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"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://scrape.cleariflow.com/v1/scrape"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"api_key\": \"<string>\",\n \"session_id\": \"<string>\",\n \"fingerprint\": \"<string>\",\n \"render\": {},\n \"render.wait_until\": \"<string>\",\n \"render.timeout_ms\": 123,\n \"render.post_load_wait_ms\": 123,\n \"render.ignore_https_errors\": true,\n \"resources\": {},\n \"resources.block\": [\n {}\n ],\n \"actions\": [\n {}\n ],\n \"actions[].type\": \"<string>\",\n \"actions[].selector\": \"<string>\",\n \"actions[].text\": \"<string>\",\n \"actions[].to\": \"<string>\",\n \"actions[].wait_ms\": 123,\n \"actions[].timeout_ms\": 123,\n \"cookies\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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://scrape.cleariflow.com/v1/scrape")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"api_key\": \"<string>\",\n \"session_id\": \"<string>\",\n \"fingerprint\": \"<string>\",\n \"render\": {},\n \"render.wait_until\": \"<string>\",\n \"render.timeout_ms\": 123,\n \"render.post_load_wait_ms\": 123,\n \"render.ignore_https_errors\": true,\n \"resources\": {},\n \"resources.block\": [\n {}\n ],\n \"actions\": [\n {}\n ],\n \"actions[].type\": \"<string>\",\n \"actions[].selector\": \"<string>\",\n \"actions[].text\": \"<string>\",\n \"actions[].to\": \"<string>\",\n \"actions[].wait_ms\": 123,\n \"actions[].timeout_ms\": 123,\n \"cookies\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://scrape.cleariflow.com/v1/scrape")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"api_key\": \"<string>\",\n \"session_id\": \"<string>\",\n \"fingerprint\": \"<string>\",\n \"render\": {},\n \"render.wait_until\": \"<string>\",\n \"render.timeout_ms\": 123,\n \"render.post_load_wait_ms\": 123,\n \"render.ignore_https_errors\": true,\n \"resources\": {},\n \"resources.block\": [\n {}\n ],\n \"actions\": [\n {}\n ],\n \"actions[].type\": \"<string>\",\n \"actions[].selector\": \"<string>\",\n \"actions[].text\": \"<string>\",\n \"actions[].to\": \"<string>\",\n \"actions[].wait_ms\": 123,\n \"actions[].timeout_ms\": 123,\n \"cookies\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"html": "<!DOCTYPE html><html>...</html>",
"meta": {
"elapsed_ms": 4521
}
}