forked from Ruby-xin/ruby8008
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_images_absolute.py
More file actions
33 lines (26 loc) · 950 Bytes
/
fix_images_absolute.py
File metadata and controls
33 lines (26 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
"""修复 HTML 中的图片路径为绝对路径"""
import re
import os
from pathlib import Path
html_file = "output/article_20260107_115239.html"
base_dir = os.path.expanduser("~/.claude/skills/wechat-burst-gen")
# 读取 HTML
with open(html_file, 'r', encoding='utf-8') as f:
html = f.read()
# 图片绝对路径
cover_image = f"{base_dir}/images/gemini_20260107_115148_1.png"
inline_images = [
f"{base_dir}/images/gemini_20260107_115205_1.png",
f"{base_dir}/images/gemini_20260107_115222_1.png",
f"{base_dir}/images/gemini_20260107_115239_1.png"
]
# 替换所有相对路径为绝对路径
html = html.replace('src="images/', f'src="{base_dir}/images/')
# 保存
with open(html_file, 'w', encoding='utf-8') as f:
f.write(html)
print(f"✅ 已修复图片路径为绝对路径")
print(f" 封面图: {cover_image}")
for idx, img in enumerate(inline_images, 1):
print(f" 配图{idx}: {img}")