# -*- coding: utf-8 -*-
import io, sys, os, ast
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")

TPL = """<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><title>__TITLE__ | 美加硕博项目库</title><style>
:root{--bg:#f7f8fa;--card:#fff;--pri:#c8102e;--pri2:#a00d24;--line:#e5e7eb;--txt:#1f2937;--sub:#6b7280;--chip:#fef2f2;--link:#c8102e;}
*{box-sizing:border-box}body{margin:0;font-family:-apple-system,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;background:var(--bg);color:var(--txt);line-height:1.65}
.wrap{max-width:1080px;margin:0 auto;padding:24px}
.crumb{font-size:13px;color:var(--sub);margin-bottom:14px}
.crumb a{color:var(--link);text-decoration:none}
.card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:22px 26px;margin-bottom:18px;box-shadow:0 1px 2px rgba(0,0,0,.03)}
h1{font-size:26px;margin:0 0 6px;color:#111}h2{font-size:17px;margin:0 0 12px;color:var(--pri);border-left:4px solid var(--pri);padding-left:10px}
.meta{display:flex;flex-wrap:wrap;gap:8px;margin:10 0 0}
.chip{background:var(--chip);color:var(--pri2);padding:3px 10px;border-radius:999px;font-size:12.5px}
.kv{display:grid;grid-template-columns:110px 1fr;row-gap:8px;font-size:14px}
.kv dt{color:var(--sub)}.kv dd{margin:0}
ul{margin:6px 0;padding-left:20px}li{margin:3px 0}
.note{background:#fffbeb;border-left:4px solid #f59e0b;padding:10px 14px;border-radius:6px;font-size:13.5px;color:#92400e;margin-top:8px}
</style></head><body><div class="wrap">
<div class="crumb"><a href="../index_main.html">← 返回项目库</a> / __CRUMB__</div>
<div class="card">
<h1>__H1__</h1>
<div class="meta">__CHIPS__</div>
<dl class="kv" style="margin-top:14px">
<dt>开设院系</dt><dd>__DEPT__</dd>
<dt>官网链接</dt><dd><a href="__URL__" target="_blank" rel="noopener">__URL__</a></dd>
<dt>截止日期</dt><dd>__DDL__</dd>
<dt>语言要求</dt><dd>__LANG__</dd>
<dt>标化考试</dt><dd>__TEST__</dd>
<dt>学费</dt><dd>__TUI__</dd>
</dl>
</div>
<div class="card"><h2>核心课程 / 学位要求</h2><ul>__CORE__</ul></div>
<div class="card"><h2>方向选修 / 特色</h2><ul>__ELECT__</ul></div>
<div class="card"><h2>备注</h2><div class="note">__NOTE__</div></div>
</div></body></html>
"""

def build(title, crumb, h1, chips, dept, url, ddl, lang, test, tui, core, elect, note):
    return (TPL
        .replace("__TITLE__", title)
        .replace("__CRUMB__", crumb)
        .replace("__H1__", h1)
        .replace("__CHIPS__", chips)
        .replace("__DEPT__", dept)
        .replace("__URL__", url)
        .replace("__DDL__", ddl)
        .replace("__LANG__", lang)
        .replace("__TEST__", test)
        .replace("__TUI__", tui)
        .replace("__CORE__", core)
        .replace("__ELECT__", elect)
        .replace("__NOTE__", note))

pages = []

# 1. UNC STOR MS
pages.append(("details/unc-stor-ms.html", build(
    title="统计/分析/数据科学硕士（MS STANDS） | 北卡教堂山",
    crumb="北卡教堂山 UNC-Chapel Hill / 统计/分析/数据科学硕士（MS STANDS）",
    h1="统计/分析/数据科学硕士（MS in Statistics, Analytics, and Data Science, STANDS）",
    chips='<span class="chip">MS</span><span class="chip">北卡教堂山 UNC-Chapel Hill</span><span class="chip">cs</span><span class="chip">STEM（OPT 36 个月）</span><span class="chip">3–4 学期；Department of Statistics and Operations Research</span>',
    dept="Department of Statistics and Operations Research (STOR)",
    url="https://catalog.unc.edu/graduate/schools-departments/statistics-operations-research/",
    ddl="catalog 页未列具体轮次（待补）",
    lang="TOEFL iBT / IELTS Academic（最低分待补）",
    test="catalog 页未列（待补）",
    tui="catalog 页未列打包学费（待补）",
    core="<li>MS in Statistics, Analytics, and Data Science（STANDS）</li><li>核心训练：高级定量思维、数据驱动决策</li><li>可在 3 学期完成，典型学制 4 学期</li>",
    elect="<li>面向数据科学与分析职业，或继续攻读相关方向研究生</li><li>STOR 系是美国少数将统计、优化、概率、随机建模集中在同一学术屋顶的系</li><li>研究方向：统计、优化、概率、随机建模，驱动数据科学/ML、商业与医疗分析</li><li>本校 STAN 本科毕业生另有 5 年 MS-STANDS 本硕连读通道（排除口径）</li>",
    note="catalog 页未列具体学分/课程列表/截止/语言/GRE/学费，整项待补；PhD in STOR 为研究型博士，留批次5。"
)))

# 2. UNC Biostatistics MS
pages.append(("details/unc-biostat-ms.html", build(
    title="生物统计硕士（MS Biostatistics） | 北卡教堂山",
    crumb="北卡教堂山 UNC-Chapel Hill / 生物统计硕士（MS Biostatistics）",
    h1="生物统计硕士（MS in Biostatistics）",
    chips='<span class="chip">MS</span><span class="chip">北卡教堂山 UNC-Chapel Hill</span><span class="chip">sci</span><span class="chip">STEM（OPT 36 个月）</span><span class="chip">研究型；Gillings 全球公共卫生学院</span>',
    dept="Department of Biostatistics, Gillings School of Global Public Health",
    url="https://catalog.unc.edu/graduate/schools-departments/biostatistics/",
    ddl="catalog 页未列具体轮次（待补）",
    lang="TOEFL iBT / IELTS Academic（最低分待补）",
    test="catalog 页未列（待补）",
    tui="catalog 页未列打包学费（待补）",
    core="<li>研究型 MS：生物统计理论与方法训练，及其在健康科学问题中的应用</li><li>方法创新：针对医学与公共卫生紧迫问题开发新统计方法</li><li>临床试验设计：加快新治疗剂评估的创新临床试验设计</li>",
    elect="<li>应用研究：传染病、癌症、心血管病、肥胖、饮用水安全</li><li>世界级生物统计方法学与实践重镇</li><li>与 Gillings 全球公共卫生学院、医学院紧密合作</li>",
    note="catalog 页未列学分/课程列表/截止/语言/GRE/学费，整项待补；本页为 UNC catalog 官方口径，半核验页。"
)))

# 3. UNC BCB MS
pages.append(("details/unc-bcb-ms.html", build(
    title="生物信息与计算生物学硕士（MS BCB） | 北卡教堂山",
    crumb="北卡教堂山 UNC-Chapel Hill / 生物信息与计算生物学硕士（MS BCB）",
    h1="生物信息与计算生物学硕士（MS in Bioinformatics and Computational Biology, BCB）",
    chips='<span class="chip">MS</span><span class="chip">北卡教堂山 UNC-Chapel Hill</span><span class="chip">sci</span><span class="chip">STEM（OPT 36 个月）</span><span class="chip">跨学科 Curriculum；含实验室轮转</span>',
    dept="Curriculum in Bioinformatics and Computational Biology (BCB)",
    url="https://catalog.unc.edu/graduate/schools-departments/bioinformatics-computational-biology/",
    ddl="catalog 页未列具体轮次（待补）",
    lang="TOEFL iBT / IELTS Academic（最低分待补）",
    test="catalog 页未列（待补）",
    tui="catalog 页未列打包学费（待补）",
    core="<li>跨学科课程：计算机科学、信息科学、数学、运筹、统计</li><li>第一年建立共同基础 + BCB 核心课</li><li>第一年完成 3 次实验室轮转（research rotations），轮转结束后加入导师实验室</li>",
    elect="<li> faculty  appointments 横跨 18 个系：医学院、牙医学院、Gillings 公卫、Eshelman 药学院、SILS、文理学院</li><li>后基因组时代生物与计算科学交叉的桥梁科学家培养</li><li>研究工作在导师实验室完成，主要由导师科研经费支持</li>",
    note="BCB 为 PhD 主导 Curriculum，但 catalog 列 MS 学位；半核验页，具体 MS 是否独立招生及学分要求待补。"
)))

# 4. UNC Biology MS
pages.append(("details/unc-biology-ms.html", build(
    title="生物学硕士（MS Biology） | 北卡教堂山",
    crumb="北卡教堂山 UNC-Chapel Hill / 生物学硕士（MS Biology）",
    h1="生物学硕士（MS in Biology）",
    chips='<span class="chip">MS</span><span class="chip">北卡教堂山 UNC-Chapel Hill</span><span class="chip">sci</span><span class="chip">STEM（OPT 36 个月）</span><span class="chip">研究型含独立研究与论文；Department of Biology</span>',
    dept="Department of Biology",
    url="https://catalog.unc.edu/graduate/schools-departments/biology/",
    ddl="catalog 页未列具体轮次（待补）",
    lang="TOEFL iBT / IELTS Academic（最低分待补）",
    test="catalog 页未列（待补）",
    tui="catalog 页未列打包学费（待补）",
    core="<li>MS 学位：要求独立研究 + Thesis</li><li>另有 MA 学位（非 Thesis 选项）</li><li>特殊课程与研究生学习方向由 Institute of Marine Sciences（Morehead City, NC）人员提供</li>",
    elect="<li>Department of Biology 同时提供 PhD in Biology</li><li>海洋科学方向：Morehead City 海洋研究所实地资源</li><li>文理学院基础生命科学方向</li>",
    note="catalog 页未列具体学分/课程列表/截止/语言/GRE/学费，整项待补；本页录 MS（Thesis 研究型），MA non-thesis 留待终判断性。"
)))

# 5. UNC ESE MS
pages.append(("details/unc-ese-ms.html", build(
    title="环境科学与工程硕士（MS ESE） | 北卡教堂山",
    crumb="北卡教堂山 UNC-Chapel Hill / 环境科学与工程硕士（MS ESE）",
    h1="环境科学与工程硕士（MS in Environmental Sciences and Engineering, ESE）",
    chips='<span class="chip">MS</span><span class="chip">北卡教堂山 UNC-Chapel Hill</span><span class="chip">eng</span><span class="chip">STEM（OPT 36 个月）</span><span class="chip">Gillings 公卫学院；物理/健康/工程/政策交叉</span>',
    dept="Department of Environmental Sciences and Engineering, Gillings School of Global Public Health",
    url="https://catalog.unc.edu/graduate/schools-departments/environmental-sciences-engineering/",
    ddl="catalog 页未列具体轮次（待补）",
    lang="TOEFL iBT / IELTS Academic（最低分待补）",
    test="catalog 页未列（待补）",
    tui="catalog 页未列打包学费（待补）",
    core="<li>跨学科课程：物理科学、健康科学、工程、政策</li><li>面向人–环境界面的环境挑战解决方案</li><li>研究方向：化学品与感染因子的环境迁移转化、化学品对人体健康的影响机制、气候变化对空气/水/健康的影响、脆弱人群暴露保护</li>",
    elect="<li>独特地设在公共卫生学院下的环境工程系</li><li>本地与全球尺度研究，职业与环境场景</li><li>议题：空气质量、水、健康、能源与资源</li>",
    note="catalog 页未列学分/课程列表/截止/语言/GRE/学费，整项待补；ESE 为 Gillings 公卫学院下的工程系，按工程口径 stem:1。"
)))

for path, html in pages:
    with open(path, "w", encoding="utf-8") as f:
        f.write(html)
    print("WROTE", path, len(html))

ast.parse("x=1")
print("AST OK, total pages:", len(pages))
