# -*- coding: utf-8 -*-
import io, sys, os, re, html as htmllib
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")

# NYU Biostatistics 详细提取
txt=open("_43_nyu_biostat.html",encoding="utf-8",errors="ignore").read()
# 去掉 HTML 标签，取纯文本
clean=re.sub(r'<script[^>]*>.*?</script>',' ',txt,flags=re.S|re.I)
clean=re.sub(r'<style[^>]*>.*?</style>',' ',clean,flags=re.S|re.I)
clean=re.sub(r'<[^>]+>',' ',clean)
clean=htmllib.unescape(re.sub(r'\s+',' ',clean)).strip()

# 找项目描述段
for kw in ["Biostatistics","degree will train","Curriculum","Admissions","Application","Deadline","GRE","TOEFL","IELTS","Tuition","Credits","36","42","Master of Science"]:
    m=re.search(r'.{0,60}'+re.escape(kw)+r'.{0,300}', clean, re.I)
    if m:
        print(f"[{kw}] {m.group(0)[:350]}")
        print()
