# -*- coding: utf-8 -*-
import io, sys, os, json, 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")
todo=json.load(open("todo_upgrade.json",encoding="utf-8"))
ctx=ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
def probe(url):
    try:
        req=urllib.request.Request(url,headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"})
        r=urllib.request.urlopen(req,timeout=12,context=ctx)
        b=r.read(); t=b.decode("utf-8","ignore")
        m=re.search(r"<title>(.*?)</title>",t,re.S|re.I)
        title=html.unescape(re.sub(r"\s+"," ",m.group(1))).strip()[:50] if m else ""
        return r.status,len(b),title
    except urllib.error.HTTPError as e:
        return e.code,0,"HTTPError"
    except Exception as e:
        return "ERR",0,type(e).__name__+":"+str(e)[:40]
for t in todo:
    if t["s"] in ("cmu","rice"):
        st,ln,ti=probe(t["url"])
        print(f"{t['s']:5} {t['det'].split('/')[-1]:42} {st} {ln:7} {ti}")
