# -*- coding: utf-8 -*-
import urllib.request, ssl, io, sys, socket
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
socket.setdefaulttimeout(10)
targets = {
  "nyu-econ ma.html": "https://as.nyu.edu/econ/graduate/ma.html",
  "nyu-econ faq.html": "https://as.nyu.edu/econ/graduate/ma/faq.html",
}
for name, url in targets.items():
    try:
        req = urllib.request.Request(url, headers={"User-Agent":"Mozilla/5.0"})
        r = urllib.request.urlopen(req, context=ctx)
        body = r.read()
        print(f"[OK {r.status}] {name}  bytes={len(body)}")
    except urllib.error.HTTPError as e:
        print(f"[HTTP {e.code}] {name}")
    except Exception as e:
        print(f"[FAIL {type(e).__name__}: {e}] {name}")
