# -*- 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)
    t = re.sub(r"\s+"," ",re.sub(r"<[^>]+>"," ",body)).strip()
    return t

for tag in ["english","cost","apply_req"]:
    t = text_of(tag)
    # 去掉重复导航：取第二次出现的页面标题之后
    print(f"\n========== {tag} ==========")
    for kw in ["TOEFL","IELTS","Duolingo","100","7.0","score","minimum","waive","Tuition","tuition","fee","Fee","Health","Housing","Living","recommendation","Recommendation","transcript","Transcript","Statement","writing sample","Writing Sample","resume","CV","three","2,","3,","$"]:
        for m in re.finditer(re.escape(kw), t):
            i=m.start(); seg=t[max(0,i-70):i+150]
            if "Skip to main" in seg or "Main navigation" in seg: continue
            print(f"[{kw}] …{seg}…")
            break
