修复(斗鱼登录): 极验 slide 挑战接入滑动验证兜底
- fullpage 返回 slide 时不再按 fullpage 重试 - 复用同一 gt/challenge 和代理执行 slide 流程 - slide 图片下载改为临时目录,避免并发串图 - slide 图片、提交验证请求复用同一代理 - 增加 fullpage/slide 分流与代理校验测试
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
import os
|
||||
import tempfile
|
||||
from collections.abc import Mapping
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
import requests
|
||||
@@ -114,27 +118,36 @@ def restore_geetest_image(input_path: str, output_path: str) -> None:
|
||||
|
||||
|
||||
# 下载图片
|
||||
def download_picture(bg: str, fullbg: str, slice: str) -> int:
|
||||
for i in range(3):
|
||||
if i == 0:
|
||||
url = "https://static.geetest.com/" + bg
|
||||
response = requests.get(url, timeout=REQUEST_TIMEOUT)
|
||||
def download_picture(
|
||||
bg: str,
|
||||
fullbg: str,
|
||||
slice: str,
|
||||
proxies: Mapping[str, str] | None = None,
|
||||
) -> int:
|
||||
"""下载并识别缺口;文件放在本次调用独立的临时目录,避免并发串图。"""
|
||||
with tempfile.TemporaryDirectory(prefix="geetest-slide-") as tmp:
|
||||
paths = {
|
||||
"bg": os.path.join(tmp, "bg.jpg"),
|
||||
"fullbg": os.path.join(tmp, "fullbg.jpg"),
|
||||
"slice": os.path.join(tmp, "slice.jpg"),
|
||||
}
|
||||
urls = {
|
||||
"bg": "https://static.geetest.com/" + bg,
|
||||
"fullbg": "https://static.geetest.com/" + fullbg,
|
||||
"slice": "https://static.geetest.com/" + slice,
|
||||
}
|
||||
for name, url in urls.items():
|
||||
response = requests.get(
|
||||
url,
|
||||
timeout=REQUEST_TIMEOUT,
|
||||
proxies=dict(proxies or {}),
|
||||
)
|
||||
response.raise_for_status()
|
||||
with open("bg.jpg", "wb") as f:
|
||||
with open(paths[name], "wb") as f:
|
||||
f.write(response.content)
|
||||
restore_geetest_image("bg.jpg", "bg.jpg")
|
||||
else:
|
||||
if i == 1:
|
||||
url = "https://static.geetest.com/" + fullbg
|
||||
response = requests.get(url, timeout=REQUEST_TIMEOUT)
|
||||
response.raise_for_status()
|
||||
with open("fullbg.jpg", "wb") as f:
|
||||
f.write(response.content)
|
||||
restore_geetest_image("fullbg.jpg", "fullbg.jpg")
|
||||
else:
|
||||
url = "https://static.geetest.com/" + slice
|
||||
response = requests.get(url, timeout=REQUEST_TIMEOUT)
|
||||
response.raise_for_status()
|
||||
with open("slice.jpg", "wb") as f:
|
||||
f.write(response.content)
|
||||
return shibie(Image.open("fullbg.jpg"), Image.open("slice.jpg"))
|
||||
if name != "slice":
|
||||
restore_geetest_image(paths[name], paths[name])
|
||||
return shibie(
|
||||
Image.open(paths["fullbg"]),
|
||||
Image.open(paths["slice"]),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user