# -*- coding: utf-8 -*-
import urllib.request, ssl, re, sys, io
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
req = urllib.request.Request("https://www.qcb-dornsife.usc.edu/masters", headers={"User-Agent":"Mozilla/5.0"})
r = urllib.request.urlopen(req, timeout=15, context=SCTX)
b = r.read().decode("utf-8", errors="ignore")
text = re.sub(r"<script[\s\S]*?</script>", " ", b, flags=re.I)
text = re.sub(r"<style[\s\S]*?</style>", " ", text, flags=re.I)
text = re.sub(r"<[^>]+>", " ", text)
text = re.sub(r"\s+", " ", text).strip()
print("=== QCB masters 全文 ===")
print(text)
print()
# 也看 href 链接
links = re.findall(r'href="([^"]+)"', b)
print("=== links 含 admission/degree/curriculum ===")
for l in links:
    if any(k in l.lower() for k in ["admission", "degree", "curriculum", "requirement", "program", "master", "phd", "course"]):
        print(l)
