# -*- coding: utf-8 -*-
import io, sys, os, re, json, urllib.request, ssl, 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={
 "c064173":"https://e-catalogue.jhu.edu/engineering/full-time-residential-programs/degree-programs/biomedical-engineering/innovation-design-master-science-engineering/",
 "ca597d7":"https://e-catalogue.jhu.edu/public-health/departments/biochemistry-molecular-biology/biochemistry-molecular-biology-scm/",
 "c03ef7d":"https://e-catalogue.jhu.edu/arts-sciences/full-time-residential-programs/degree-programs/biophysics/biophysical-chemistry-design-biotechnology-master-science/",
 "c529fb8":"https://e-catalogue.jhu.edu/arts-sciences/full-time-residential-programs/degree-programs/economics/economics-master-arts/",
 "ca25d43":"https://e-catalogue.jhu.edu/engineering/full-time-residential-programs/degree-programs/leadership-education/global-innovation-leadership-engineering-master-science/",
 "c97be4c":"https://e-catalogue.jhu.edu/arts-sciences/advanced-academic-programs/programs/applied-economics-master-science/",
 "c5ed8dc":"https://e-catalogue.jhu.edu/arts-sciences/advanced-academic-programs/programs/center-biotechnology-education/bioinformatics-master-science/",
 "c13629c":"https://e-catalogue.jhu.edu/arts-sciences/advanced-academic-programs/programs/financial-economics-master-science/",
 "c785e3d":"https://e-catalogue.jhu.edu/arts-sciences/advanced-academic-programs/programs/geographic-information-systems-master-science/",
}
hdr={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"}
for h,u in URLS.items():
    try:
        req=urllib.request.Request(u,headers=hdr)
        r=urllib.request.urlopen(req,context=ctx,timeout=20)
        b=r.read(); t=b.decode("utf-8","ignore")
        t=html.unescape(re.sub(r"<script.*?</script>","",t,flags=re.S|re.I))
        t=html.unescape(re.sub(r"<style.*?</style>","",t,flags=re.S|re.I))
        plain=re.sub(r"<[^>]+>"," ",t); plain=re.sub(r"\s+"," ",plain)
        open(f"_23_{h}.txt","w",encoding="utf-8").write(plain)
        low=plain.lower()
        flags=[w for w in ["online","part-time","part time","full-time","full time","residential","on-campus","evening","hybrid","remote"] if w in low]
        print(h,r.status,len(b),"B","|",",".join(flags))
    except Exception as e:
        print(h,"ERR",type(e).__name__,str(e)[:80])
