Datadome 协议接口
ℹ️ 该任务类型必须传入代理proxy信息,暂不支持proxyless
⚠️ 通过 createTask 创建任务, 然后通过 getTaskResult 获取识别结果
任务类型type
如下
DataDomeSliderTask
必须传入代理
创建任务
通过 createTask 创建任务
注意 你一定需要观察 captchaUrl
中的 t
参数是否等于 fe
,如果 t=bv
表示你的ip直接被禁止,你必须更换IP
参数结构
属性 | 类型 | Required | 说明 |
---|---|---|---|
type | String | Yes | DataDomeSliderTask |
websiteURL | String | Yes | 目标网页的地址。可以在网站上的任何地方,甚至在会员区域。 |
captchaUrl | String | Yes | 验证码Url,该URL中必须包含t=fe , 如果 t=bv 表示你的IP已经被禁止 |
proxy | String | No | 学习如何使用代理 |
userAgent | String | No | userAgent头 |
请求示例
txt
POST https://api.capsolver.com/createTask
Host: api.capsolver.com
Content-Type: application/json
json
{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "DatadomeSliderTask",
"websiteURL": "https://www.websiteurl.com/registry",
"captchaUrl": "https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAAAAMA1QGvUmJwyYoAwpyjNg%3D%3D&hash=789361B674144528D0B7EE76B35826&cid=6QAEcL8coBYTi9tYLmjCdyKmNNyHz1xwM2tMHHGVd_Rxr6FsWrb7H~a04csMptCPYfQ25CBDmaOZpdDa4qwAigFnsrzbCkVkoaBIXVAwHsjXJaKYXsTpkBPtqJfLMGN&t=fe&referer=https%3A%2F%2bck.websiteurl.com%2Fclient%2Fregister%2FYM4HJV%3Flang%3Den&s=40070&e=3e531bd3b30650f2e810ac72cd80adb5eaa68d2720e804314d122fa9e84ac25d",
"proxy": "158.120.100.23:334:user:pass",
"userAgent": "your_user_agent"
}
}
响应示例
json
{
"errorId": 0,
"status": "idle",
// 请记录此ID
"taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006"
}
获取结果
使用 getTaskResult 方法获取识别结果
根据系统负载,您将在 1s
到 20s
的时间间隔内得到结果
请求示例
txt
POST https://api.capsolver.com/getTaskResult
Host: api.capsolver.com
Content-Type: application/json
json
{
"clientKey": "YOUR_API_KEY",
"taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006"
}
响应示例
json
{
"errorId": 0,
"errorCode": null,
"errorDescription": null,
"solution": {
"userAgent": "",
"cookie": "datadome=yzj_BK...S0; Max-Age=31536000; Domain=.hermes.com; Path=/; Secure; SameSite=Lax"
},
"status": "ready"
}
使用 SDK 请求
python
#pip install --upgrade capsolver
#export CAPSOLVER_API_KEY='...'
import capsolver
# capsolver.api_key = "..."
solution = capsolver.solve({
"type": "DatadomeSliderTask",
"websiteURL": "https://bck.websiteurl.com/",
"captchaUrl": "https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAAAAMA1QGvUmJwyYoAwpyjNg%3D%3D&hash=789361B674144528D0B7EE76B35826&cid=6QAEcL8coBYTi9tYLmjCdyKmNNyHz1xwM2tMHHGVd_Rxr6FsWrb7H~a04csMptCPYfQ25CBDmaOZpdDa4qwAigFnsrzbCkVkoaBIXVAwHsjXJaKYXsTpkBPtqJfLMGN&t=fe&referer=https%3A%2F%2bck.websiteurl.com%2Fclient%2Fregister%2FYM4HJV%3Flang%3Den&s=40070&e=3e531bd3b30650f2e810ac72cd80adb5eaa68d2720e804314d122fa9e84ac25d",
"proxy": "158.120.100.23:334:user:pass",
"userAgent": "your_user_agent"
})
go
package main
import (
"fmt"
capsolver_go "github.com/capsolver/capsolver-go"
"log"
)
func main() {
// first you need to install sdk
//go get github.com/capsolver/capsolver-go
capSolver := capsolver_go.CapSolver{ApiKey: "..."}
solution, err := capSolver.Solve(map[string]any{
"type": "DatadomeSliderTask",
"websiteURL": "https://bck.websiteurl.com/",
"captchaUrl": "https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAAAAMA1QGvUmJwyYoAwpyjNg%3D%3D&hash=789361B674144528D0B7EE76B35826&cid=6QAEcL8coBYTi9tYLmjCdyKmNNyHz1xwM2tMHHGVd_Rxr6FsWrb7H~a04csMptCPYfQ25CBDmaOZpdDa4qwAigFnsrzbCkVkoaBIXVAwHsjXJaKYXsTpkBPtqJfLMGN&t=fe&referer=https%3A%2F%2bck.websiteurl.com%2Fclient%2Fregister%2FYM4HJV%3Flang%3Den&s=40070&e=3e531bd3b30650f2e810ac72cd80adb5eaa68d2720e804314d122fa9e84ac25d",
"proxy": "158.120.100.23:334:user:pass",
"userAgent": "your_user_agent",
})
if err != nil {
log.Fatal(err)
return
}
fmt.Println(solution)
}
Sample Code
python
# 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": 'DatadomeSliderTask',
"websiteURL": "https://bck.websiteurl.com/",
"captchaUrl": "https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAAAAMA1QGvUmJwyYoAwpyjNg%3D%3D&hash=789361B674144528D0B7EE76B35826&cid=6QAEcL8coBYTi9tYLmjCdyKmNNyHz1xwM2tMHHGVd_Rxr6FsWrb7H~a04csMptCPYfQ25CBDmaOZpdDa4qwAigFnsrzbCkVkoaBIXVAwHsjXJaKYXsTpkBPtqJfLMGN&t=fe&referer=https%3A%2F%2bck.websiteurl.com%2Fclient%2Fregister%2FYM4HJV%3Flang%3Den&s=40070&e=3e531bd3b30650f2e810ac72cd80adb5eaa68d2720e804314d122fa9e84ac25d",
"proxy": "158.120.100.23:334:user:pass",
"userAgent": "your_user_agent"
}
}
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("cookie")
if status == "failed" or resp.get("errorId"):
print("Solve failed! response:", res.text)
return
cookie = capsolver()
print(cookie)
go
package main
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"time"
)
type capSolverResponse struct {
ErrorId int32 `json:"errorId"`
ErrorCode string `json:"errorCode"`
ErrorDescription string `json:"errorDescription"`
TaskId string `json:"taskId"`
Status string `json:"status"`
Solution map[string]any `json:"solution"`
}
func capSolver(apiKey string, taskData map[string]any) (*capSolverResponse, error) {
uri := "https://api.capsolver.com/createTask"
res, err := request(uri, map[string]any{
"clientKey": apiKey,
"task": taskData,
})
if err != nil {
return nil, err
}
if res.ErrorId == 1 {
return nil, errors.New(res.ErrorDescription)
}
uri = "https://api.capsolver.com/getTaskResult"
for i := 0; i < 120; i++ {
time.Sleep(time.Second * 3) // delay
res, err = request(uri, map[string]any{
"clientKey": apiKey,
"taskId": res.TaskId,
})
if err != nil {
return nil, err
}
if res.ErrorId == 1 {
return nil, errors.New(res.ErrorDescription)
}
if res.Status == "ready" {
return res, err
}
}
return res, errors.New("solve timeout")
}
func request(uri string, payload any) (*capSolverResponse, error) {
payloadBytes, err := json.Marshal(payload)
if err != nil {
return nil, err
}
resp, err := http.Post(uri, "application/json", bytes.NewReader(payloadBytes))
if err != nil {
return nil, err
}
defer resp.Body.Close()
responseData, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
capResponse := &capSolverResponse{}
err = json.Unmarshal(responseData, capResponse)
if err != nil {
return nil, err
}
return capResponse, nil
}
func main() {
apikey := "YOUR_API_KEY"
res, err := capSolver(apikey, map[string]any{
"type": "DatadomeSliderTask",
"websiteURL": "https://bck.websiteurl.com/",
"captchaUrl": "https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAAAAMA1QGvUmJwyYoAwpyjNg%3D%3D&hash=789361B674144528D0B7EE76B35826&cid=6QAEcL8coBYTi9tYLmjCdyKmNNyHz1xwM2tMHHGVd_Rxr6FsWrb7H~a04csMptCPYfQ25CBDmaOZpdDa4qwAigFnsrzbCkVkoaBIXVAwHsjXJaKYXsTpkBPtqJfLMGN&t=fe&referer=https%3A%2F%2bck.websiteurl.com%2Fclient%2Fregister%2FYM4HJV%3Flang%3Den&s=40070&e=3e531bd3b30650f2e810ac72cd80adb5eaa68d2720e804314d122fa9e84ac25d",
"proxy": "158.120.100.23:334:user:pass",
"userAgent": "your_user_agent",
})
if err != nil {
panic(err)
}
fmt.Println(res.Solution)
}