# -*- coding: utf-8 -*-
import io, sys, re, os
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
BASE = r"D:\work buddy\2026-11-05-14-15-52"
def text_of(tag):
    html = open(os.path.join(BASE,f"_hds_{tag}.html"),encoding="utf-8").read()
    body = re.sub(r"<script.*?</script>"," ",html,flags=re.S)
    body = re.sub(r"<style.*?</style>"," ",body,flags=re.S)
    return re.sub(r"\s+"," ",re.sub(r"<[^>]+>"," ",body)).strip()

cost = text_of("cost")
j = cost.find("Data Science Master")
print("=== 费用页 CSE/DS 硕士段 ===")
print(cost[j-200:j+1200] if j>=0 else "未定位 CSE/DS 段")

eng = text_of("english")
k = eng.find("Alternate")
print("\n=== 语言页 备用考试段 ===")
print(eng[k-200:k+700] if k>=0 else "无 Alternate 段")
k2 = eng.find("undergraduate degree")
print("\n=== 豁免段 ===")
print(eng[k2-100:k2+500])

req = text_of("apply_req")
for kw in ["Three letters","Statement of purpose","Writing sample","resume","Personal statement","full-time","degree","credits","half-time"]:
    m=re.search(re.escape(kw),req)
    if m:
        i=m.start(); print(f"\n[{kw}] …{req[max(0,i-80):i+220]}…")
