fix: 添加代理日志输出并重构reCAPTCHA任务的异常处理逻辑
This commit is contained in:
parent
aa302bdb58
commit
a20d49a0e2
21
onoe.py
21
onoe.py
@ -221,6 +221,7 @@ def gettoken(proxy, r=2):
|
||||
}
|
||||
try:
|
||||
proxy_str = db.get_proxy(proxy)
|
||||
logger.info(f"[代理] => {proxy_str}")
|
||||
url = 'https://graphql.api.dailymotion.com/oauth/token'
|
||||
response = requests.post(url, headers=headers, data=data, proxies={"http": proxy_str, "https": proxy_str})
|
||||
token = response.json()['access_token']
|
||||
@ -262,7 +263,7 @@ def solve_recaptcha_v3_with_proxy(
|
||||
|
||||
last_error = None
|
||||
for attempt in range(1, max_task_retries + 1):
|
||||
# try:
|
||||
try:
|
||||
encoded_query = quote(keyword, safe="")
|
||||
payload = {
|
||||
"clientKey": "CAP-A76C932D4C6CCB3CA748F77FDC07D996",
|
||||
@ -290,15 +291,15 @@ def solve_recaptcha_v3_with_proxy(
|
||||
return result["solution"]["gRecaptchaResponse"]
|
||||
time.sleep(polling_interval)
|
||||
|
||||
# raise TimeoutError(f"任务 {task_id} 在轮询 {max_poll_attempts} 次后未完成")
|
||||
#
|
||||
# except Exception as e:
|
||||
# last_error = e
|
||||
# if attempt < max_task_retries:
|
||||
# time.sleep(2)
|
||||
# continue
|
||||
# else:
|
||||
# break
|
||||
raise TimeoutError(f"任务 {task_id} 在轮询 {max_poll_attempts} 次后未完成")
|
||||
|
||||
except Exception as e:
|
||||
last_error = e
|
||||
if attempt < max_task_retries:
|
||||
time.sleep(2)
|
||||
continue
|
||||
else:
|
||||
break
|
||||
|
||||
raise Exception(f"创建或获取 reCAPTCHA v3 token 失败: {last_error}")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user