BotDeflector: BotDefectorの問題を解決する
ヒント
タスクはcreateTaskメソッドで作成し、結果はgetTaskResultメソッドで取得します。
タスクタイプ type は以下の通りです。
AntiBotdeflectorTaskProxyLess
タスクの作成
createTaskメソッドでタスクを作成します。
タスクオブジェクトの構造
| Properties | Type | Required | Description |
|---|---|---|---|
| type | String | Required | AntiBotdeflectorTaskProxyLess |
| websiteURL | String | Required | 現在のホームページのURL |
| domain | String | Required | pow/get または icon/get エンドポイントで使用されるドメイン名(例:botdefector.eu) |
| flowToken | String | Required | Webサイトでは、botReflectorJwtTokenと呼ばれることがあります。例: eyJhbGciOiJ... |
注意
domainパラメータとwebsiteURLパラメータは、必ずしも同じドメイン名ではありません。区別してください。
リクエスト例
POST https://api.capsolver.com/createTask
Host: api.capsolver.com
Content-Type: application/json
{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "AntiBotdeflectorTaskProxyLess", // Required
"websiteURL": "https://exaple.com/", // Required
"domain":"exaple.com", // Required
"flowToken":"eyJhbGciOiJI1...", // Required
}
}レスポンス例
{
"errorId": 0,
"errorCode": "",
"errorDescription": "",
"taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006"
}結果の取得
認識結果を取得するには、getTaskResultメソッドを使用します。
ウェブサイトやプロキシによっては、1秒から20秒の間に結果が得られます。
リクエスト例
POST https://api.capsolver.com/getTaskResult
Host: api.capsolver.com
Content-Type: application/json
{
"clientKey": "YOUR_API_KEY",
"taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006"
}レスポンス例
{
"errorId": 0,
"taskId": "646825ef-9547-4a29-9a05-50a6265f9d8a",
"status": "ready",
"solution": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOiI1ZmMyOGEwMi04Z..."
}
}SDKリクエストの使用
# pip install --upgrade capsolver
# export CAPSOLVER_API_KEY='...'
import capsolver
# capsolver.api_key = "..."
solution = capsolver.solve({
"type": "AntiBotdeflectorTaskProxyLess",
"websiteURL": "https://exaple.com/",
"domain":"exaple.com",
"flowToken":"eyJhbGciOiJI1...",
})サンプルコード
# pip install requests
import requests
import time
api_key = "YOUR_API_KEY" # your api key of capsolver
def capsolver():
payload = {
"clientKey": api_key,
"task": {
"type": "AntiBotdeflectorTaskProxyLess",
"websiteURL": "https://exaple.com/",
"domain":"exaple.com",
"flowToken":"eyJhbGciOiJI1...",
}
}
res = requests.post("https://api.capsolver.com/createTask", json=payload)
resp = res.json()
task_id = resp.get("taskId")
if not task_id:
print("Failed to create task:", res.text)
return
print(f"Got taskId: {task_id} / Getting result...")
while True:
time.sleep(1) # delay
payload = {"clientKey": api_key, "taskId": task_id}
res = requests.post("https://api.capsolver.com/getTaskResult", json=payload)
resp = res.json()
status = resp.get("status")
if status == "ready":
return resp.get("solution", {}).get("token")
if status == "failed" or resp.get("errorId"):
print("Solve failed! response:", res.text)
return
token = capsolver()
print(token)