# -*- coding: utf-8 -*-
import io, sys, os, re, html
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
for det in ["dartmouth-engineering-sciences-ms.html","yale-personalized-medicine-applied-engineering.html"]:
    b=open("_31_"+det,"rb").read()
    t=html.unescape(b.decode("utf-8","ignore"))
    p=re.sub(r"<script[\s\S]*?</script>"," ",t); p=re.sub(r"<style[\s\S]*?</style>"," ",p)
    p=re.sub(r"<[^>]+>"," ",p); p=re.sub(r"\s+"," ",p)
    print("="*25,det,"len",len(p))
    # 找正文起始
    for anchor in ["Program The Master","The MS degree","Areas & Options","Prerequisites","Courses & Requirements","Admission Requirements","Academic Information","Application Deadline","Tuition"]:
        i=p.find(anchor)
        if i>=0:
            print("\n---",anchor,"---")
            print(p[i:i+500])
