fix:优化爬虫链路
This commit is contained in:
@@ -13,10 +13,16 @@ def _is_mostly_chinese(text: str) -> bool:
|
||||
|
||||
|
||||
def translate_to_chinese(text: str) -> str:
|
||||
"""将文本翻译成中文,失败或已是中文则返回原文。Google 失败时尝试 MyMemory。"""
|
||||
"""将文本翻译成中文,失败或已是中文则返回原文。
|
||||
|
||||
说明:
|
||||
- 默认关闭外部翻译(deep_translator),直接返回原文,避免因网络或代理问题阻塞整条流水线。
|
||||
- 如需开启翻译,可显式设置环境变量 TRANSLATE_DISABLED=0。
|
||||
"""
|
||||
if not text or not text.strip():
|
||||
return text
|
||||
if os.environ.get("TRANSLATE_DISABLED", "0") == "1":
|
||||
# 默认禁用翻译:TRANSLATE_DISABLED 未设置时视为开启(值为 "1")
|
||||
if os.environ.get("TRANSLATE_DISABLED", "1") == "1":
|
||||
return text
|
||||
s = str(text).strip()
|
||||
if len(s) > 2000:
|
||||
|
||||
Reference in New Issue
Block a user