# -*- coding: utf-8 -*-
import io,sys,ssl,urllib.request,re
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 get(u):
    req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)"})
    try:
        with urllib.request.urlopen(req,context=ctx,timeout=20) as r:
            b=r.read(); enc=r.headers.get_content_charset() or "utf-8"
            return r.status,b.decode(enc,errors="replace"),r.geturl()
    except Exception as e:
        return None,"ERR "+repr(e),u
def clean(b):
    t=re.sub(r"<script.*?</script>","",b,flags=re.S); t=re.sub(r"<style.*?</style>","",t,flags=re.S)
    t=re.sub(r"<[^>]+>"," ",t); return re.sub(r"\s+"," ",t)
for p in ["/careers/career-outcomes/","/careers/internship-statistics/"]:
    st,body,url=get("https://finmath.uchicago.edu"+p)
    print("\n=====",p,"->",st,"len=",len(body))
    if st==200:
        print("  TXT:",clean(body)[:2000])
        for l in re.findall(r'href="([^"]+)"',body):
            if re.search(r'pdf|outcome|employ|salary|stat',l,re.I): print("  L:",l)
