fix: 添加异常处理以增强请求稳定性和错误日志记录
This commit is contained in:
parent
b7e8fa4977
commit
f70a441dd8
7
main.py
7
main.py
@ -79,8 +79,15 @@ def get_searchInfo(keyword, level, headers, proxy_name, r=2):
|
||||
'http': proxy_string,
|
||||
'https': proxy_string,
|
||||
}
|
||||
try:
|
||||
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:
|
||||
resinfo = jsondata.get("list")
|
||||
except Exception:
|
||||
|
Loading…
x
Reference in New Issue
Block a user