# -*- coding: utf-8 -*-
import io, sys, os, urllib.request, ssl, re
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
ctx=ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
urls={
 "meng":"https://engineering.vanderbilt.edu/academics/master-of-engineering-degree/",
 "msdeg":"https://engineering.vanderbilt.edu/academics/graduate/masters-degrees-in-engineering/",
}
for k,u in urls.items():
    try:
        req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0"})
        r=urllib.request.urlopen(req,timeout=12,context=ctx); b=r.read()
        open("_18_"+k+".txt","wb").write(b); print(k,r.status,len(b),u)
        for l in sorted(set(re.findall(r'href="([^"]+)"',b.decode("utf-8","ignore")))):
            if "meng" in l.lower() or "degree" in l.lower() or "cps" in l.lower() or "esi" in l.lower():
                print("   ",l)
    except Exception as e:
        print(k,"ERR",type(e).__name__,str(e)[:80],u)
