import ssl, urllib.request, re, sys, io
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 fetch(u):
    req = urllib.request.Request(u, headers={"User-Agent": "Mozilla/5.0"})
    return urllib.request.urlopen(req, context=ctx, timeout=25).read().decode("utf-8", "ignore")

for tag, u in [("MAIN","https://economics.uchicago.edu/masters-programs/master-arts-economics"),
               ("APPLY","https://economics.uchicago.edu/masters-programs/master-arts-economics/apply")]:
    h = fetch(u)
    links = re.findall(r'href="([^"]+)"', h)
    links = [l for l in links if re.search(r'(deadline|proficiency|english|tuition|fee|financial|aid|admiss|social-science|ssd|apply|cost)', l, re.I)]
    print("="*25, tag)
    for l in sorted(set(links)):
        print("  ", l)
