# -*- coding: utf-8 -*-
import io, sys, os, json, re, ssl, urllib.request, html
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
todo=json.load(open("todo_upgrade.json",encoding="utf-8"))
items=todo["list"] if isinstance(todo,dict) else todo
ctx=ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
targets=[x for x in items if x.get("s") in ("notre","jhu") and "PhD" not in x.get("deg","") and "doctoral" not in x.get("det","")]
out={}
for x in targets:
    u=x.get("url",""); det=os.path.basename(x.get("det",""))
    try:
        req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0"})
        r=urllib.request.urlopen(req,timeout=8,context=ctx); b=r.read(); code=r.status
        txt=html.unescape(re.sub(r"<script[\s\S]*?</script>|<style[\s\S]*?</style>"," ",b.decode("utf-8","ignore")))
        txt=re.sub(r"<[^>]+>"," ",txt); txt=re.sub(r"\s+"," ",txt)
        out[det]={"code":code,"bytes":len(b),"textlen":len(txt),"url":u}
        print(code,len(b),"B",det,"| text",len(txt))
    except Exception as e:
        out[det]={"code":"ERR","err":str(e)[:60],"url":u}
        print("ERR",str(e)[:50],det)
json.dump(out,open("_probe32c.json","w",encoding="utf-8"),ensure_ascii=False,indent=1)
