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)[:60]

urls = [
 ("MIT-DEDP","https://dusp.mit.edu/masters/masc-data-economics-and-policy-design"),
 ("MIT-DEDP2","https://dedp.mit.edu/"),
 ("USC-bursar","https://bursar.usc.edu/tuition-fees/graduate-tuition/"),
 ("USC-bursar2","https://bursar.usc.edu/tuition-fees/"),
]
for k,u in urls:
    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)
        for m in re.finditer(r'[^.]*\$[\d,]+[^.]*\.?', txt):
            s=m.group(0).strip()
            if any(w in s.lower() for w in ["tuition","per unit","per credit","per semester","fee","cost"]):
                print("  $:", s[:150])
    print()
