# -*- coding: utf-8 -*-
import io,sys,json,os,urllib.request,ssl,re
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding="utf-8")
b=r"D:\work buddy\2026-11-05-14-15-52"
todo=json.load(open(os.path.join(b,"todo_upgrade.json"),encoding="utf-8"))
row=[t for t in todo if t.get("s")=="rice" and "computer-science" in (t.get("url") or "")]
for t in row:
    print("URL:",t.get("url"))
    print("deg:",t.get("deg"),"| det:",t.get("det"),"| disc:",t.get("disc"))
ctx=ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
for t in row:
    u=t["url"]
    try:
        req=urllib.request.Request(u,headers={"User-Agent":"Mozilla/5.0"})
        raw=urllib.request.urlopen(req,context=ctx,timeout=25).read().decode("utf-8","ignore")
        print("\n===",u,"len=",len(raw))
        tt=re.sub(r"<script[\s\S]*?</script>","",raw)
        tt=re.sub(r"<style[\s\S]*?</style>","",tt)
        tt=re.sub(r"<[^>]+>"," ",tt); tt=re.sub(r"&nbsp;"," ",tt); tt=re.sub(r"&amp;","&",tt); tt=re.sub(r"\s+"," ",tt)
        print(tt[:1800])
    except Exception as e:
        print("ERR",u,e)
