fix async

This commit is contained in:
jxxghp
2025-07-31 13:32:47 +08:00
parent ee4d6d0db3
commit 6873de7243
7 changed files with 133 additions and 18 deletions

View File

@@ -352,7 +352,11 @@ class SiteParserBase(metaclass=ABCMeta):
headers=req_headers).get_res(url=url)
if res is not None and res.status_code in (200, 500, 403):
if req_headers and "application/json" in str(req_headers.get("Accept")):
return json.dumps(res.json())
try:
return json.dumps(res.json())
except (json.JSONDecodeError, ValueError) as e:
logger.error(f"{self._site_name} API响应JSON解析失败: {e}")
return ""
else:
# 如果cloudflare 有防护,尝试使用浏览器仿真
if under_challenge(res.text):