import re, sys, io, urllib.request, ssl
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
ctx = ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
def probe(url):
    try:
        req = urllib.request.Request(url, headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"})
        with urllib.request.urlopen(req, timeout=12, context=ctx) as resp:
            return resp.status, resp.read().decode("utf-8","ignore")
    except urllib.error.HTTPError as e:
        return e.code, ""
    except Exception as e:
        return "ERR", str(e)[:50]

pages = [
 ("CMU-INI-apply","https://www.cmu.edu/ini/admissions/howtoapply.html"),
 ("CMU-Tepper-BA","https://www.cmu.edu/tepper/programs/master-business-analytics"),
 ("CMU-Tepper-MSM","https://www.cmu.edu/tepper/programs/master-science-management"),
 ("Duke-AIPI-req","https://masters.pratt.duke.edu/apply/requirements/"),
 ("UW-MDSAI","https://uwaterloo.ca/future-graduate-students/programs/by-faculty/math/data-science-and-artificial-intelligence-co-op-master-data"),
 ("UW-ECE","https://uwaterloo.ca/future-graduate-students/programs/by-faculty/engineering/electrical-and-computer-engineering-co-op-master-engineering"),
 ("WUSTL-bulletin-stats","https://bulletin.wustl.edu/grad/artsci/degrees/stats-data-science-stats-conc-ma/"),
 ("Illinois-catalog-MSPE","https://catalog.illinois.edu/graduate/las/policy-economics-ms"),
 ("Geo-bioinfo","https://bioinformatics.georgetown.edu/"),
 ("McGill-MMA","https://www.mcgill.ca/desautels/node/2946694"),
]
for k,u in pages:
    st, body = probe(u)
    print(f"=== {k} HTTP {st} len {len(body)} ===")
    if st==200 and body:
        txt=re.sub(r'<script[\s\S]*?</script>','',body); txt=re.sub(r'<style[\s\S]*?</style>','',txt)
        txt=re.sub(r'<[^>]+>',' ',txt); txt=re.sub(r'\s+',' ',txt)
        hits=0
        for m in re.finditer(r'[^.]*\b(GRE|GMAT)\b[^.]*\.?', txt, re.I):
            print("  -", m.group(0).strip()[:150]); hits+=1
            if hits>=4: break
        if hits==0: print("  (页面未出现 GRE/GMAT 字样)")
    print()
