HCaptcha 协议接口
⚠️ 通过 createTask 创建任务, 然后通过 getTaskResult 获取识别结果
现在我们已满足几乎所有高分数网站要求,并同时支持invisible
draw a box
等问题类型
任务类型type
如下
HCaptchaTask
必须传入代理HCaptchaEnterpriseTaskProxyLess
无需代理或已内置代理
hCaptcha 服务不稳定公告
最近由于 hCaptcha 图片更新等问题导致服务不稳定,对此我们非常抱歉,如果是出现新图片导致服务不可用的话请等待我们更新,如有其他问题请随时联系我们
如果你使用 HCaptchaTask 获得了无效的 token,请联系我们
每个网站都有一些特殊的设置,通常在我们设置之后都可以正常工作
创建任务
通过 createTask 创建任务
参数结构
属性 | 类型 | Required | 说明 |
---|---|---|---|
type | String | Required | HCaptchaTask HCaptchaTaskProxyLess |
websiteURL | String | Required | hCaptcha 网页地址,一般固定值。 |
websiteKey | String | Required | hCaptcha 网站密钥,固定值。 |
isInvisible | Boolean | Optional | Set true if it's a invisible captcha |
proxy | String | Optional | 学习如何使用代理 |
enterprisePayload | Object | Optional | 在 hCaptcha 企业版的某些实现中使用的自定义数据。在大多数情况下,您将其视为网络请求中的 rqdata。 注意:如果你提交带有 data 参数的验证码,你可能需要提供 userAgent,该值应该与您在与目标网站交互时使用的 User-Agent 相匹配。 |
getCaptcha | Object | Optional | 如果遇到无效的 token,你可以使用这个参数,参考文章Solve HCaptcha |
userAgent | String | Optional | request userAgent, 通常你不需要设置此参数 |
请求示例
txt
POST https://api.capsolver.com/createTask
Host: api.capsolver.com
Content-Type: application/json
json
{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "HCaptchaTaskProxyLess",
//HCaptchaTask,HCaptchaTaskProxyLess,HCaptchaEnterpriseTask,HCaptchaEnterpriseTaskProxyLess
"websiteURL": "",
"websiteKey": "00000000-0000-0000-0000-000000000000",
"invisible": true,
// 这里是示例,具体的值你要去你的目标网站上
"enterprisePayload": {
"rqdata": ""
},
"getCaptcha": "fetch request base64 content",
"proxy": "http:ip:port:user:pass"
// socks5:ip:port:user:pass
}
}
响应示例
json
{
"errorId": 0,
"errorCode": "",
"errorDescription": "",
"taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006" // 请记录此ID
}
获取结果
使用 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": "xxx", //userAgent
"expireTime": 1671615324290, //过期时间
"timestamp": 1671615024290,
"captchaKey": "E0_xxx",
"gRecaptchaResponse": "3AHJ....." //响应token
},
"status": "ready"
}
使用 SDK 请求
python
# pip install --upgrade capsolver
# export CAPSOLVER_API_KEY='...'
import capsolver
# capsolver.api_key = "..."
solution = capsolver.solve({
"type": "HCaptchaTaskProxyLess",
"websiteURL": "",
"websiteKey": "00000000-0000-0000-0000-000000000000",
})
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
//export CAPSOLVER_API_KEY='...' or
//capSolver := CapSolver{ApiKey:"..."}
capSolver := capsolver_go.CapSolver{}
solution, err := capSolver.Solve(map[string]any{
"type": "HCaptchaTaskProxyLess",
"websiteURL": "",
"websiteKey": "00000000-0000-0000-0000-000000000000",
})
if err != nil {
log.Fatal(err)
return
}
fmt.Println(solution)
}