CloudFlare5s 任务
通过 createTask方法 创建识别任务,然后通过 getTaskResult 方法 获取识别结果
任务类型
任务类型 | 描述 | 价格(美元) |
|---|---|---|
CloudFlare5STask | CloudFlare5S 解决方案 | $1.2/k |
创建任务
通过以下方法创建任务
请求host: https://api.ez-captcha.com
请求api: https://api.ez-captcha.com/createTask
请求format:POST application/json
备注
CloudFlare5s要求同IP、同 UA、同TLS,UA请使用我们返回的UA(header字段),TLS请用我们返回的TLS版本(tlsVersion字段).
我们返回的User-agent和TLS可能会随着版本更新变化,请关注我们返回的User-agent、TLS版本.
代理账号密码不可为空,否则代理会存在无法联通的情况。
如果在某个时间段内需要大批量的请求,请提前联系我们添加主机。
参数
参数 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
clientKey | string | yes | 你的clientkey |
type | string | yes | CloudFlare5STask |
websiteURL | string | yes | 网站url |
proxy | string | yes | 使用的代理,如 |
rqData | Object | optional | 如果添加mode字段,请求将会以Post的方式发送,注意要写明是FORM还是JSON。跟在后边的表示要提交的字段。如
|
示例
POST https://api.ez-captcha.com/createTask
Content-Type: application/json
{
"clientKey": "YourClientKey",
"task": {
"websiteURL": "https://xxx.com",
"type": "CloudFlare5STask",
"proxy": "http://username:password@ip:port",
"rqData":{ //可选
"mode":"FORM", //JSON或者FORM 根据网页的提交方式确定 如果需要以POST形式发包,你必须添加该值
"name1":"value",//你的字段
"name2":123456,
//如果需要上传cookie,可以添加cookie字段
"cookie":{
"key1":"value1",
"key2":"value2"
}
//如果需要上传额外的header,可以添加header字段
"header":{
"authority":"api.x.com",
"authorization":"Bearer ....",
}
...
},
}
}返回示例
{
"errorId": 0,
"errorCode": "",
"errorDescription": "",
"taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006" // Please save this ID for next step
}获取结果
使用 getTaskResult 方法获取结果
请求 host: https://api.ez-captcha.com
请求 api: https://api.ez-captcha.com/getTaskResult
请求 format:POST application/json
请求示例
POST https://api.ez-captcha.com/getTaskResult
Content-Type: application/json
{
"clientKey":"YOUR_API_KEY",
"taskId": "TASKID OF CREATETASK" //ID created by createTask method
}返回参数
参数 | 类型 | 描述 |
|---|---|---|
errorId | Integer | 错误提示: 0 - 没有错误,1 - 有错误 |
errorCode | string | 错误代码, 点这里查看全部错误列表 |
errorDescription | string | 错误详细描述 |
status | String | processing - 正在识别中,请3秒后重试 |
solution | Object | 识别结果,不同类型的任务结果会有所区别。 |
返回示例
{
"errorId": 0,
"errorCode": null,
"errorDescription": null,
"solution": {
{
"header": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"accept-encoding": "gzip, deflate, br, zstd",
...
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
},
"tlsVersion":"chrome131",
"cookies": {
"cf_clearance": "suAu.vzSYU4etZ2lc1FVhVhoAtKrKjHvbLn1.qY8m0E-1736763580-1.2.1.1-NM03fWRNYkN_gYFO1n1nlzwe9MtiNmm9YIz7ujq_Jmh_FyJvg2YA7ImuXyD_9ouZ2XYy.G73Gude_Qpzx04subKCPhHeaRr1qTKicxeGV9p6GhU_z75.6OTi.FlDFXe7ogCYwyPMn3xZKzFkzpDqpHBUv5uq40LF7Z07PIEPizwE8XZuhlVBhVkgulsWu4QCkStR95HbJxGNmKOf0h2PZSJPSStyCV5XwpmAIuZy3Zhfm46r4gDAbh7q.Isx_nMjpo6WCGYrpQrFHAfZQWd6NshmfxQyVJmItilb1p2evZrt3aVQOhmaTpKOzM4E5Rhtc8i2xYtm_hUk9ToGQm_7_g",
...
},
"body": "<!DOCTYPE html>\n<html lang="en">\n<head>\n ..."
}
},
"status": "ready"
}响应说明
识别成功:当
errorId等于0并且status等于ready,结果在solution里面。正在识别中:当
errorId等于0并且status等于processing,请1-3秒后重试。出错了:当
errorId大于0,请根据errorDescription了解出错误信息 全部错误说明
代码示例
import threading
import time
import requests
import json
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
def test():
start_time = time.time()
data = {
"clientKey": "YourClientKey",
"task": {
"type": "CloudFlare5STask",#
"websiteURL": "https://xxx.com",
"proxy": "http://username:password@ip:port"
}
}
resp = requests.post("https://api.ez-captcha.com/createTask", json=data,verify=False)
task_id = resp.json()['taskId']
print(f"task_id: {task_id}")
for _ in range(30):
data = {
"clientKey": "YourClientKey",#
"taskId": task_id
}
resp = requests.post("https://api.ez-captcha.com/getTaskResult", json=data,verify=False)
if "header" in resp.text:
resp_json = json.loads(resp.text)
print(f"Headers: {resp_json.get('solution', {}).get('header', {})}")
print(f"CF Clearance: {resp_json.get('solution', {}).get('cookies', {}).get('cf_clearance', '')}")
end_time = time.time()
print(f"time: {end_time - start_time}")
break;
elif "errorDesc" in resp.text:
print(resp.text)
break;
time.sleep(1)
if __name__ == '__main__':
test()