from pathlib import Path
import zipfile, os, shutil, re, textwrap
src = Path("/mnt/data/taiwan_stock_line_landing_page_upgraded.zip")
work = Path("/mnt/data/tw_v2_work")
out = Path("/mnt/data/taiwan_stock_line_landing_page_v2.zip")
if work.exists():
shutil.rmtree(work)
work.mkdir()
with zipfile.ZipFile(src, "r") as z:
z.extractall(work)
# Find html entry
html_files = list(work.rglob("*.html"))
if html_files:
html = html_files[0]
content = html.read_text(encoding="utf-8", errors="ignore")
# Add v2 enhancement styles/content before closing body
addon = r"""