mirror of
https://github.com/ravizhan/geetest-v3-click-crack.git
synced 2025-12-05 14:52:51 +08:00
增加重试功能
This commit is contained in:
@@ -34,7 +34,8 @@ model = Model()
|
||||
crack.gettype()
|
||||
crack.get_c_s()
|
||||
crack.ajax()
|
||||
pic_content = crack.get_pic()
|
||||
for retry in range(6):
|
||||
pic_content = crack.get_pic(retry)
|
||||
# 检测文字位置
|
||||
small_img, big_img = model.detect(pic_content)
|
||||
# 判断点选顺序
|
||||
@@ -45,10 +46,12 @@ for i in result_list:
|
||||
top = str(round((i[1] + 30) / 333 * 10000))
|
||||
point_list.append(f"{left}_{top}")
|
||||
# 验证请求
|
||||
# 注意 请求此函数时请确保全过程时间大于等于4s
|
||||
# 注意 请确保验证与获取图片间隔不小于2s
|
||||
# 否则会报 duration short
|
||||
result = crack.verify(point_list)
|
||||
print(result)
|
||||
if eval(result)["data"]["result"] == "success":
|
||||
break
|
||||
```
|
||||
|
||||
# 协议
|
||||
|
||||
18
crack.py
18
crack.py
@@ -417,13 +417,19 @@ Bm1Zzu+l8nSOqAurgQIDAQAB
|
||||
resp = self.session.get("https://api.geetest.com/ajax.php", params=params).text
|
||||
return json.loads(resp[22:-1])["data"]
|
||||
|
||||
def get_pic(self):
|
||||
def get_pic(self,retry=0):
|
||||
params = {
|
||||
"is_next": "true",
|
||||
"type": "click",
|
||||
"gt": self.gt,
|
||||
"challenge": self.challenge,
|
||||
"lang": "zh-cn",
|
||||
"callback": "geetest_" + str(int(round(time.time() * 1000))),
|
||||
}
|
||||
if retry == 0:
|
||||
url = "https://api.geevisit.com/get.php"
|
||||
params.update(
|
||||
{
|
||||
"is_next": "true",
|
||||
"https": "true",
|
||||
"protocol": "https://",
|
||||
"offline": "false",
|
||||
@@ -432,12 +438,14 @@ Bm1Zzu+l8nSOqAurgQIDAQAB
|
||||
"isPC": True,
|
||||
"autoReset": True,
|
||||
"width": "100%",
|
||||
"callback": "geetest_" + str(int(round(time.time() * 1000))),
|
||||
}
|
||||
resp = self.session.get("https://api.geevisit.com/get.php", params=params).text
|
||||
)
|
||||
else:
|
||||
url = "https://api.geetest.com/refresh.php"
|
||||
resp = self.session.get(url, params=params).text
|
||||
data = json.loads(resp[22:-1])["data"]
|
||||
self.pic_path = data["pic"]
|
||||
pic_url = "https://" + data["resource_servers"][0][:-1] + data["pic"]
|
||||
pic_url = "https://" + data["image_servers"][0][:-1] + data["pic"]
|
||||
return self.session.get(pic_url).content
|
||||
|
||||
def verify(self, points: list):
|
||||
|
||||
18
main.py
18
main.py
@@ -8,7 +8,9 @@ import httpx
|
||||
t = time.time()
|
||||
|
||||
tt = time.time()
|
||||
reg = httpx.get(f"https://www.geetest.com/demo/gt/register-click-official?t={str(round(time.time()))}").json()
|
||||
reg = httpx.get(
|
||||
f"https://www.geetest.com/demo/gt/register-click-official?t={str(round(time.time()))}"
|
||||
).json()
|
||||
print(time.time() - tt)
|
||||
|
||||
crack = Crack(reg["gt"], reg["challenge"])
|
||||
@@ -29,13 +31,16 @@ print(time.time() - tt)
|
||||
|
||||
model = Model()
|
||||
|
||||
for retry in range(6):
|
||||
tt = time.time()
|
||||
pic_content = crack.get_pic()
|
||||
pic_content = crack.get_pic(retry)
|
||||
print(time.time() - tt)
|
||||
|
||||
tt = time.time()
|
||||
ttt = tt = time.time()
|
||||
small_img, big_img = model.detect(pic_content)
|
||||
print(f"检测到小图: {len(small_img.keys())}个,大图: {len(big_img)} 个,用时: {time.time() - tt}s")
|
||||
print(
|
||||
f"检测到小图: {len(small_img.keys())}个,大图: {len(big_img)} 个,用时: {time.time() - tt}s"
|
||||
)
|
||||
tt = time.time()
|
||||
result_list = model.siamese(small_img, big_img)
|
||||
print(f"文字配对完成,用时: {time.time() - tt}")
|
||||
@@ -45,12 +50,13 @@ for i in result_list:
|
||||
left = str(round((i[0] + 30) / 333 * 10000))
|
||||
top = str(round((i[1] + 30) / 333 * 10000))
|
||||
point_list.append(f"{left}_{top}")
|
||||
wait_time = 4.0 - (time.time() - t)
|
||||
wait_time = 2.0 - (time.time() - ttt)
|
||||
time.sleep(wait_time)
|
||||
tt = time.time()
|
||||
result = json.loads(crack.verify(point_list))
|
||||
print(result)
|
||||
print(time.time() - tt)
|
||||
if result["data"]["result"] == "success":
|
||||
break
|
||||
total_time = time.time() - t
|
||||
print(f"总计耗时(含等待{wait_time}s): {total_time}")
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
httpx~=0.27.2
|
||||
httpx[http2]~=0.27.2
|
||||
cryptography~=43.0.0
|
||||
onnxruntime~=1.19.0
|
||||
opencv-python~=4.10.0.84
|
||||
|
||||
Reference in New Issue
Block a user