# -*- coding: utf-8 -*-
import urllib.request, ssl, sys, io, traceback
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
SCTX = ssl.create_default_context(); SCTX.check_hostname=False; SCTX.verify_mode=ssl.CERT_NONE
url = "https://catalog.upenn.edu/graduate/programs/applied-positive-psychology-mapp/"
try:
    req = urllib.request.Request(url, headers={"User-Agent":"Mozilla/5.0","Referer":"https://catalog.upenn.edu/graduate/programs/"})
    r = urllib.request.urlopen(req, timeout=30, context=SCTX)
    body = r.read()
    print("status", r.status, "rawlen", len(body))
    text = body.decode("utf-8","ignore")
    print("decoded", len(text))
    open("_raw_mapp.html","w",encoding="utf-8").write(text)
    print("saved")
except Exception as e:
    traceback.print_exc()
