import os, re, html, io, sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
BASE = os.path.dirname(os.path.abspath(__file__))
def clean(raw):
    t=re.sub(r'<script[\s\S]*?</script>',' ',raw)
    t=re.sub(r'<style[\s\S]*?</style>',' ',t)
    t=re.sub(r'<[^>]+>',' ',t)
    return html.unescape(re.sub(r'\s+',' ',t)).strip()
for tag in ["rice-macc","rice-meecon","rice-mfin"]:
    raw=open(os.path.join(BASE,f"_26_{tag}.txt"),encoding="utf-8").read()
    t=clean(raw)
    print("="*30,tag,"len",len(t))
    # 找项目描述段
    for kw in ["The Master","The MEEcon","Master of Finance","designed to","professional","prerequisite","credit hours","curriculum","requirement","full-time","part-time","online","tuition","GRE","GMAT","TOEFL","IELTS"]:
        i=t.lower().find(kw.lower())
        if i>=0:
            print(f"  [{kw}] …{t[max(0,i-60):i+200]}…")
    print()
