fix: 添加异常处理以增强请求稳定性和错误日志记录
This commit is contained in:
parent
b7e8fa4977
commit
f70a441dd8
11
main.py
11
main.py
@ -79,8 +79,15 @@ def get_searchInfo(keyword, level, headers, proxy_name, r=2):
|
|||||||
'http': proxy_string,
|
'http': proxy_string,
|
||||||
'https': proxy_string,
|
'https': proxy_string,
|
||||||
}
|
}
|
||||||
response = requests.get(endpoint, params=params, proxies=proxies)
|
try:
|
||||||
jsondata = response.json()
|
response = requests.get(endpoint, params=params, proxies=proxies)
|
||||||
|
jsondata = response.json()
|
||||||
|
except Exception as e:
|
||||||
|
if r < 0:
|
||||||
|
logger.exception(f"[Requested] 未知:{e}, keyword: {keyword}, l: {level}")
|
||||||
|
else:
|
||||||
|
time.sleep((3 - r) * 5)
|
||||||
|
return get_searchInfo(keyword, level, headers, proxy_name, r - 1)
|
||||||
try:
|
try:
|
||||||
resinfo = jsondata.get("list")
|
resinfo = jsondata.get("list")
|
||||||
except Exception:
|
except Exception:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user