CloudFlareTask: CloudFlare5秒盾协议接口

通过 createTask方法 创建识别任务,然后通过 getTaskResult 方法 获取识别结果

创建任务

通过 createTask方法 创建识别任务

请求节点: 国际节点 https://api.yescaptcha.com 国内节点 https://cn.yescaptcha.com

请求地址: https://api.yescaptcha.com/createTask

请求格式:POST application/json

对象结构

属性

类型

必须

说明

属性

类型

必须

说明

type

string

CloudFlareTaskS2 15 POINTS

websiteURL

string

网页地址,需要识别的地址。

userAgent

string

自定义Ua值 仅CloudFlareTaskS2类型支持

waitLoad

Bool

是否必须等待页面加载完成(如果你需要完整内容)

proxy

String

代理地址,支持以下格式:

  • 有密码http/https代理:http://user:pass@45.91.239.47:62930

  • 没有密码http/https代理:http://45.91.239.47:62930

  • 没有密码的socks5代理: socks5://5.252.190.52:64585

  • !不支持带密码的socks5代理!

注意:如果需要权限,请将43.154.193.54加入白名单

注意:CF盾对代理要求较高,请使用国际代理,如果报ERROR_CAPTCHA_UNSOLVABLE错误,请更换代理再试一下,也可以联系我们测试是否能过(绝大部份情况都能过)

注意:不要使用本地代理(127.0.0.1、localhost、192.168.x.x、172.0.x.x),本地代理只有你自己电脑才能访问,服务器访问不了!

请求示例

{ "clientKey": "cc9c18d3e263515c2c072b36a7125eecc078618f", "task": { "type": "CloudFlareTaskS2", "websiteURL": "https://nowsecure.nl", "proxy": "http://JN3wWChA:Dsg7ckfv@45.91.239.47:62930", //请用你自己的代理,这个只是演示 "waitLoad": false // 是否需要等待加载完成(如果你需要完整内容就写true,会增加识别时间) } }

响应示例

{ "errorId": 0, "errorCode": "", "errorDescription": "", "taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006" // 请记录此ID }

获取结果

使用 getTaskResult 方法获取识别结果

请求节点: 国际节点 https://api.yescaptcha.com 国内节点 https://cn.yescaptcha.com

请求地址: https://api.yescaptcha.com/getTaskResult

请求格式:POST application/json

根据系统负载,您将在 10s 到 80s 的时间间隔内得到结果

请求示例

{ "clientKey":"cc9c18d3e263515c2c072b36a7125eecc078618f3", "taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006" }

响应结果

参数

类型

说明

参数

类型

说明

errorId

Integer

错误提示: 0 - 没有错误,1 - 有错误

errorCode

string

错误代码,点这里查看全部错误列表

errorDescription

string

错误详细描述

status

String

processing - 正在识别中,请3秒后重试
ready - 识别完成,在solution参数中找到结果

solution

Object

识别结果,不同类型的任务结果会有所区别。

user_agent

string

使用的ua值,请使用返回的值进行后续请求

cookies

Object

返回的cookies值,请使用返回的值进行后续请求,

一般cloudflare5s盾的cookies包含cf_clearance

这个cookie值有一定的有效期,有的网站长达1小时

所以1小时内不需要重复请求,但是也需要注意请求的频率

request_headers

Object

请求时的headers,建议你在使用时带上这个值

放到你的请求的headers中!

headers

Object

请求成功后响应的headers

content

string

返回的网页内容源码

响应示例

 

响应说明

  1. 请使用返回的ua值、cookie值以及创建任务的代理ip进行后续操作,因为cloudflare要求三者一致

  2. 请先确认是否为5s盾,判断方法:源码中包含?__cf_chl_rt_tk字符串的为5s盾

    Please confirm whether the shield is 5s, judge method: the source code contains? The string is 5s shield

  3. 如果不是5s盾,但是使用requests等工具请求的时候标题出现:Just a moment...请稍后,并且响应码为403,则可能只是tls指纹拦截了,使用curl_cffi等库或者其他方法就可以绕过继续请求,真的5s盾使用正确的tls指纹也无法请求,如:https://nowsecure.nl网站。

    If it's not a 5s shield, but requests using tools such as. Or please wait, and the response code is 403, then it may just be the TLS fingerprint intercepted, using curl or other methods can bypass the continue request, the Real 5s shield using the correct TLS fingerprint can not request, https://nowsecure.nl websites.

  4. 通过本接口拿到结果后,在一定时间内有效(如1小时),可以不需要重复请求,但是要注意请求频率,频率过高可能会Cloudflare会封IP地址。

    Once you get the result through this interface, it will be available for a certain period of time (say, 1 hour) , so you don't need to repeat the request, but be aware of the frequency of the request, which can cause Cloudflare to block the IP address.

  5. 接口还在内测中,有任何问题请联系客服对接技术沟通

    Interface is still in the internal test, any problems please contact the customer service docking technology communication

 

如何判断5s盾:

 

关于指纹库

一部份网站只需要解决指纹问题,就不会弹验证码,也不需要使用接口

这里是模拟Chrome浏览器指纹,其他语言只要解决指纹问题就可以正常请求。

 

测试DEMO