# -*- coding: utf-8 -*-
import urllib.request, ssl, io, sys, os, re
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
SCTX = ssl.create_default_context(); SCTX.check_hostname=False; SCTX.verify_mode=ssl.CERT_NONE
UA = {"User-Agent":"Mozilla/5.0"}
cands = [
    ("UNC African Studies", "https://catalog.unc.edu/graduate/schools-departments/african-american-africa-studies/"),
    ("UNC Asian Studies", "https://catalog.unc.edu/graduate/schools-departments/asian-studies/"),
    ("UNC Classics", "https://catalog.unc.edu/graduate/schools-departments/classics/"),
    ("UNC English", "https://catalog.unc.edu/graduate/schools-departments/english/"),
    ("UNC History", "https://catalog.unc.edu/graduate/schools-departments/history/"),
    ("UNC Philosophy", "https://catalog.unc.edu/graduate/schools-departments/philosophy/"),
    ("UNC Religion", "https://catalog.unc.edu/graduate/schools-departments/religion/"),
    ("UNC Sociology", "https://catalog.unc.edu/graduate/schools-departments/sociology/"),
    ("UNC Anthropology", "https://catalog.unc.edu/graduate/schools-departments/anthropology/"),
    ("UNC Geography", "https://catalog.unc.edu/graduate/schools-departments/geography/"),
]
for name, url in cands:
    try:
        req = urllib.request.Request(url, headers=UA)
        r = urllib.request.urlopen(req, timeout=12, context=SCTX)
        body = r.read()
        # 检查是否有 master 字样
        txt = body.decode("utf-8", errors="ignore").lower()
        has_ma = "master of arts" in txt or "master of science" in txt
        print(f"OK  {r.status} {len(body):>7}B  MA={has_ma}  {name}")
    except Exception as e:
        print(f"ERR {type(e).__name__:>20}  {name}")
