关注它,不迷路。
本文章中所有内容仅供学习交流,不可用于任何商业用途和非法用途,否则后果自负,如有侵权,请联系作者立即删除!
1.平台地址
https://dashboard.ez-captcha.com/#/register?inviteCode=ArTRhaGRJkp
点击左下角的 阅读原文 可以直达。
2.hcaptcha验证码demo
demo地址:
https://accounts.hcaptcha.com/demo
3.抓包分析
弹出验证码后,点击相应的图片,通过它的验证再抓包:
验证通过后,点击 Submit 按钮:
发现提交了这些参数:
email字段为空,而 g-recaptcha-response 字段 和 h-captcha-response 字段 提交的内容是一样的。它的响应是这样的:
4.打码平台需要提交的参数
可以访问下面的地址查看详细介绍:
https://ezcaptcha.atlassian.net/wiki/spaces/IS/pages/13860865/HCaptcha
与用户相关的其实只有 "websiteURL" 和 "websiteKey" 字段。
"websiteURL"其实就是它的一级域名:
https://accounts.hcaptcha.com
而 "websiteKey" 字段 可以通过抓包得知:
它这个网站返回的 "websiteKey" 好像都一样:
"a5f74b19-9e45-40e0-b45d-47ff91b7a6c2"
5.请求源码
下面的代码由打码平台的技术提供,在此感谢:
import random
import threading
import time
import requests
cap_key = "你的客户端密钥"
requests.packages.urllib3.disable_warnings()
def cap_create_task(websiteURL, websiteKey, taskType, isInvisible=False) -> str:
url = "https://api.ez-captcha.com/createTask"
data = {
"clientKey": cap_key,
"task": {
"websiteURL": websiteURL,
"websiteKey": websiteKey,
"type": taskType,
}
}
try:
result = requests.post(url, json=data, verify=False, timeout=8)
result = result.json()
#print(result)
taskId = result.get('taskId')
if taskId is not None:
return taskId
except Exception as e:
print(e)
def cap_get_response(taskID: str):
times = 0
start_time = time.time()
while times < 120:
try:
url = "https://api.ez-captcha.com/getTaskResult"
data = {
"clientKey": cap_key,
"taskId": taskID
}
print ("结果获取中.....")
result = requests.post(url, json=data, verify=False, timeout=8).json()
solution = result.get('solution', {})
if solution:
response = solution.get('token')
if response:
#print(f"消耗时间 {time.time()-start_time}s", response)
return response
except Exception as e:
print(e)
times += 1
time.sleep(1)
return ""
def demo():
sitekey = "a5f74b19-9e45-40e0-b45d-47ff91b7a6c2"
url = "https://accounts.hcaptcha.com"
type = "HcaptchaTaskProxyless"
taskId = cap_create_task(url, sitekey, type, False)
res = cap_get_response(taskId)
if res != "":
data = {"email":"","g-recaptcha-response":res,"h-captcha-response":res}
url = "https://accounts.hcaptcha.com/demo"
result = requests.post(url, data=data, verify=False, timeout=8)
print(result.text)
if __name__ == '__main__':
demo()
请求结果如图:
初次请求,可能在10s-20s以内,属正常情况,后面再请求就比较快了。
今天的文章就分享到这里,后续分享更多的技巧,敬请期待。