# -*- coding: utf-8 -*-
import io, sys, re, html
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
BASE = r"D:\work buddy\2026-11-05-14-15-52"
h = open(BASE + r"_mae_inst.html", encoding="utf-8").read()
body = re.sub(r"<script.*?</script>", " ", h, flags=re.S)
body = re.sub(r"<style.*?</style>", " ", body, flags=re.S)
body = html.unescape(re.sub(r"<[^>]+>", " ", body))
body = re.sub(r"\s+", " ", body).strip()
# 去掉导航：定位 "Application Instructions" 第二次出现之后
print("=== 正文后半（关键词段）===")
for kw in ["STEM", "credit", "tuition", "TOEFL", "IELTS", "Duolingo", "GRE", "deadline",
           "January", "semester", "MAE", "M.A.", "Analytical Political", "writing sample",
           "video", "questionnaire", "recommend", "fee", "GPA", "English"]:
    for m in re.finditer(kw, body, re.I):
        a=max(0,m.start()-80); b=min(len(body),m.end()+110)
        print(f"[{kw}] ...{body[a:b]}...")
        break
print("\n=== 正文 2500 字起 ===")
print(body[2500:5200])
