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

for k in ["apply","home","curr"]:
    b=body(k)
    print("="*90,k)
    for m in re.finditer(r"\$\s?\d[\d,]*",b):
        s=max(0,m.start()-80);e=min(len(b),m.end()+80)
        print("  $:",b[s:e])
    # 申请费句
    for m in re.finditer(r"[Aa]pplication fee",b):
        s=max(0,m.start()-60);e=min(len(b),m.end()+160)
        print("  FEE:",b[s:e])
    # 录取画像
    for kw in ["GPA","grade point","average","median","GRE","GMAT","profile","Profile","class of","Class of"]:
        m=re.search(re.escape(kw),b)
        if m:
            s=max(0,m.start()-70);e=min(len(b),m.end()+140)
            print(f"  [{kw}]:",b[s:e])

# curriculum 课程号
b=body("curr")
print("="*90,"CURRICULUM PUBPOL/ENG courses")
for m in re.finditer(r"[A-Z]{2,6}\s?\d{4}[^.]{0,90}",b):
    print("  ",m.group(0).strip())
