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"})
        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]
def clean(b):
    t=re.sub(r'<script[\s\S]*?</script>','',b); t=re.sub(r'<style[\s\S]*?</style>','',t)
    t=re.sub(r'<[^>]+>',' ',t); return re.sub(r'\s+',' ',t)

pages=[
 ("UW-MDSAI-req","https://uwaterloo.ca/data-science/graduate-programs/admission-requirements"),
 ("UW-ECE-req","https://uwaterloo.ca/future-graduate-students/admissions/admission-and-english-language-proficiency-requirements"),
 ("Geo-adm","https://bioinformatics.georgetown.edu/admissions/"),
]
for k,u in pages:
    st,body=probe(u)
    print(f"=== {k} HTTP {st} len {len(body)} ===")
    if st==200:
        t=clean(body); hits=0
        for m in re.finditer(r'[^.]*\b(GRE|GMAT)\b[^.]*\.?', t, re.I):
            print("  -", m.group(0).strip()[:170]); hits+=1
            if hits>=4: break
        if hits==0:
            for kw in ["test","standardized","score"]:
                j=t.lower().find(kw)
                if j>=0: print(f"  [{kw}]", t[max(0,j-70):j+150])
    print()
