# -*- coding: utf-8 -*-
import io, sys, re, os, subprocess
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
B = r"D:\work buddy\2026-11-05-14-15-52"
f = os.path.join(B, "publish", "美加硕士项目查询库", "美加硕士项目查询库_单文件版.html")
t = open(f, encoding="utf-8").read()
ms = re.findall(r"<script>(.*?)</script>", t, re.S)
tmp = os.path.join(B, "_single_check.js")
open(tmp, "w", encoding="utf-8").write("\n".join(ms))
r = subprocess.run(["node", "--check", tmp], capture_output=True, text=True)
print("node exit:", r.returncode)
print(r.stdout, r.stderr[:800])
# 统计内嵌对象键数
m = re.search(r"const DETAIL_PAGES=(\{.*?\});\nconst DOCDEG", t, re.S)
print("内嵌对象提取:", bool(m))
os.remove(tmp)
