# -*- 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")
b=open("_32_jhu-ehe-ms.html","rb").read()
txt=html.unescape(re.sub(r"<script[\s\S]*?</script>|<style[\s\S]*?</style>"," ",b.decode("utf-8","ignore")))
txt=re.sub(r"<[^>]+>"," ",txt); txt=re.sub(r"\s+"," ",txt)
# 定位项目标题第二次出现（首次在导航）
idxs=[m.start() for m in re.finditer(r"Environmental Health and Engineering, Master of Science",txt)]
print("hits",idxs)
if len(idxs)>=2:
    seg=txt[idxs[1]:idxs[1]+2600]
    print(seg)
else:
    # 找 Whiting 下 EHE 关键词
    i=txt.find("Whiting")
    print(txt[i:i+1200])
