# -*- coding: utf-8 -*-
import io, sys, re, html
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
BASE = r"D:\work buddy\2026-11-05-14-15-52"

def strip(t):
    t = re.sub(r"<script.*?</script>", " ", t, flags=re.S)
    t = re.sub(r"<style.*?</style>", " ", t, flags=re.S)
    t = re.sub(r"<[^>]+>", " ", t)
    t = html.unescape(t)
    return re.sub(r"\s+", " ", t).strip()

for tag in ["duke_econ", "harvard_cse", "harvard_eas"]:
    h = open(BASE + rf"_{tag}.html", encoding="utf-8").read()
    body = strip(h)
    print(f"========== {tag} 全文 ({len(body)}) ==========")
    print(body)
    print()
