Webスクレイピング API
非同期ジョブ
jobs エンドポイントはスクレイピングタスクをキューに入れ、ステータスと結果をポーリングできます — 高ボリュームや遅いページに最適です。
POST
/
v1
/
jobs
非同期ジョブ
curl --request POST \
--url https://scrape.cleariflow.com/v1/jobs \
--header 'Content-Type: application/json' \
--data '
{
"request": {},
"priority": 123
}
'import requests
url = "https://scrape.cleariflow.com/v1/jobs"
payload = {
"request": {},
"priority": 123
}
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({request: {}, priority: 123})
};
fetch('https://scrape.cleariflow.com/v1/jobs', 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/jobs",
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([
'request' => [
],
'priority' => 123
]),
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/jobs"
payload := strings.NewReader("{\n \"request\": {},\n \"priority\": 123\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/jobs")
.header("Content-Type", "application/json")
.body("{\n \"request\": {},\n \"priority\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://scrape.cleariflow.com/v1/jobs")
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 \"request\": {},\n \"priority\": 123\n}"
response = http.request(request)
puts response.read_body{
"job_id": "550e8400-e29b-41d4-a716-446655440000"
}
はじめに
ベース URL
https://scrape.cleariflow.com/v1/jobs
ジョブの作成
同期エンドポイントと同じScrapeRequest ペイロードで非同期スクレイピングジョブをキューに追加します。
リクエスト例
curl -X POST 'https://scrape.cleariflow.com/v1/jobs' \
-H 'Content-Type: application/json' \
-d '{
"request": {
"api_key": "YOUR_UNIQUE_API_KEY",
"url": "https://example.com"
},
"priority": 10
}'
{
"job_id": "550e8400-e29b-41d4-a716-446655440000"
}
ジョブ作成パラメータ
Object
必須
同期スクレイピングエンドポイントと同じフィールド(
url、render、actions、cookies など)を持つ ScrapeRequest オブジェクト。Integer
ジョブ優先度。値が大きいほど先に処理されます。デフォルト: 0。
ジョブステータスの取得
ID でジョブをポーリングし、ステータスを確認し、完了後に結果を取得します。ベース URL
https://scrape.cleariflow.com/v1/jobs/{job_id}
リクエスト例
curl 'https://scrape.cleariflow.com/v1/jobs/550e8400-e29b-41d4-a716-446655440000'
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "running"
}
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "done",
"result": {
"ok": true,
"html": "<!DOCTYPE html><html>...</html>",
"meta": {
"elapsed_ms": 8123
}
}
}
ジョブステータス値
| ステータス | 説明 |
|---|---|
queued | ジョブがキューで待機中。 |
running | ブラウザセッションがアクティブ。 |
done | スクレイピング完了。result に出力が含まれる。 |
failed | スクレイピング失敗。error に説明が含まれる。 |
レスポンスパラメータ
String
非同期ジョブの一意の識別子。
String
現在のジョブステータス:
queued、running、done、failed。Object
スクレイピング結果オブジェクト(同期エンドポイントレスポンスと同じ構造)。
status が done の場合に返されます。String
エラーメッセージ。
status が failed の場合に返されます。Object
ジョブ実行に関する追加メタデータ。
⌘I
非同期ジョブ
curl --request POST \
--url https://scrape.cleariflow.com/v1/jobs \
--header 'Content-Type: application/json' \
--data '
{
"request": {},
"priority": 123
}
'import requests
url = "https://scrape.cleariflow.com/v1/jobs"
payload = {
"request": {},
"priority": 123
}
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({request: {}, priority: 123})
};
fetch('https://scrape.cleariflow.com/v1/jobs', 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/jobs",
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([
'request' => [
],
'priority' => 123
]),
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/jobs"
payload := strings.NewReader("{\n \"request\": {},\n \"priority\": 123\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/jobs")
.header("Content-Type", "application/json")
.body("{\n \"request\": {},\n \"priority\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://scrape.cleariflow.com/v1/jobs")
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 \"request\": {},\n \"priority\": 123\n}"
response = http.request(request)
puts response.read_body{
"job_id": "550e8400-e29b-41d4-a716-446655440000"
}