# -*- coding: utf-8 -*-
import io, sys, os, re, json
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")
h=open("相似专业推荐_一期骨架.html",encoding="utf-8").read()
# 提取 DATA 行
m=re.search(r"const DATA=(\{.*?\});\nconst PROGS",h,re.S)
print("DATA 注入:",bool(m))
if m:
    d=json.loads(m.group(1))
    print("项目数:",len(d["programs"]),"| 学校数:",len(d["schools"]))
    usc=[p for p in d["programs"] if p["s"]=="usc" and re.search(r"business analytics",p["en"],re.I)]
    ber=[p for p in d["programs"] if p["s"]=="berkeley" and re.search(r"analytics|Statistics and Data|Information Management|Information and Data",p["en"],re.I)]
    print("USC BA 候选:",[p["en"] for p in usc])
    print("UCB 替代候选:",[p["en"] for p in ber])
# 提取 script 块写临时 js 供 node --check
scripts=re.findall(r"<script>(.*?)</script>",h,re.S)
print("script 块:",len(scripts))
open("_sim_page_check.js","w",encoding="utf-8").write(scripts[-1])
