|
|
@@ -103,7 +103,9 @@ def _extract_images(doc, drug_name):
|
|
|
if ext.lower() not in ('jpg', 'jpeg', 'png', 'gif', 'bmp'):
|
|
|
ext = 'png'
|
|
|
# 用 rId hash 防止重复
|
|
|
- fname = f"{drug_name}_{rId}.{ext}"
|
|
|
+ # 清理药名中的特殊字符,避免 URL 编码问题
|
|
|
+ safe_name = re.sub(r'[\s()() ]+', '_', drug_name).strip('_')
|
|
|
+ fname = f"{safe_name}_{rId}.{ext}"
|
|
|
fpath = os.path.join(IMAGES_DIR, fname)
|
|
|
if not os.path.exists(fpath):
|
|
|
with open(fpath, 'wb') as f:
|