# -*- coding: utf-8 -*-
import io, sys, os, urllib.request, ssl, re, html
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
ctx=ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
urls={
"c1b6b67 MHS Biochem":"https://e-catalogue.jhu.edu/public-health/departments/biochemistry-molecular-biology/biochemistry-molecular-biology-mhs/",
"ca597d7 ScM Biochem":"https://e-catalogue.jhu.edu/public-health/departments/biochemistry-molecular-biology/biochemistry-molecular-biology-scm/",
"c6cfbd0 MHS Biostat":"https://e-catalogue.jhu.edu/public-health/departments/biostatistics/biostatistics-mhs/",
"c682af5 ScM Biostat":"https://e-catalogue.jhu.edu/public-health/departments/biostatistics/biostatistics-scm/",
"cb5871a MHS GlobHealthEcon":"https://e-catalogue.jhu.edu/public-health/departments/international-health/global-health-economics-mhs/",
"c42b996 MHS HEOR":"https://e-catalogue.jhu.edu/public-health/departments/health-policy-management/health-economics-outcomes-research-mhs/",
"cab39af MHS HFM":"https://e-catalogue.jhu.edu/public-health/departments/health-policy-management/health-finance-management-mhs/",
"c03ef7d MS BiophysChem":"https://e-catalogue.jhu.edu/arts-sciences/full-time-residential-programs/degree-programs/biophysics/biophysical-chemistry-design-biotechnology-master-science/",
"c529fb8 MA Economics":"https://e-catalogue.jhu.edu/arts-sciences/full-time-residential-programs/degree-programs/economics/economics-master-arts/",
"c97be4c MS ApplEcon(AAP)":"https://e-catalogue.jhu.edu/arts-sciences/advanced-academic-programs/programs/applied-economics-master-science/",
"c5ed8dc MS Bioinfo(AAP)":"https://e-catalogue.jhu.edu/arts-sciences/advanced-academic-programs/programs/center-biotechnology-education/bioinformatics-master-science/",
"c13629c MS FinEcon(AAP)":"https://e-catalogue.jhu.edu/arts-sciences/advanced-academic-programs/programs/financial-economics-master-science/",
}
for k,u in urls.items():
    try:
        req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0"})
        r=urllib.request.urlopen(req,timeout=20,context=ctx); b=r.read(); code=r.status
        raw=b.decode("utf-8","ignore")
        t=html.unescape(re.sub(r"<script.*?</script>","",raw,flags=re.S)); t=html.unescape(re.sub(r"<style.*?</style>","",t,flags=re.S))
        t=re.sub(r"<[^>]+>"," ",t); t=html.unescape(re.sub(r"\s+"," ",t))
        pt=re.search(r"(part-time|part time|online|evening|weekend|Advanced Academic|full-time|full time)",t,re.I)
        print(k,code,len(b),"形态词=",pt.group(0) if pt else "-")
        open("_21_"+k.split()[0]+".txt","wb").write(b)
    except Exception as e:
        print(k,"ERR",type(e).__name__,str(e)[:60])
