# -*- 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. Rice MAI
pages.append(("details/rice-mai-ms.html", build(
    title="人工智能硕士（Master of Artificial Intelligence, MAI） | 莱斯大学",
    crumb="莱斯 Rice University / 人工智能硕士（Master of Artificial Intelligence, MAI）",
    h1="人工智能硕士（Master of Artificial Intelligence, MAI）",
    chips='<span class="chip">MAI</span><span class="chip">莱斯 Rice University</span><span class="chip">cs</span><span class="chip">STEM（OPT 36 个月）</span><span class="chip">30 学分；非 Thesis；全日制；CS 系专业硕士</span>',
    dept="Department of Computer Science, George R. Brown School of Engineering",
    url="https://csweb.rice.edu/academics/graduate-programs/master-artificial-intelligence",
    ddl="官网页未列具体轮次（待补）；$85 申请费（信息 Sessions 参加者豁免）",
    lang="TOEFL iBT / IELTS Academic（最低分待补）",
    test="官网页未列（待补）",
    tui="官网页未列打包学费（待补）",
    core="<li>30 学分非 Thesis 专业型硕士</li><li>AI 基础课程：设计、部署、维护大规模 AI 系统</li><li>团队 Capstone：从概念到交付构建可运行的 AI 应用</li>",
    elect="<li>Rice CS 系主办，面向 CS 本科毕业生及技术背景工程师/科学家/技术人员</li><li>研究方向：AI/ML、计算机视觉、机器人、安全、计算生物学</li><li>行业实习与就业：医疗、能源、航空航天、金融等休斯顿产业生态</li>",
    note="Rice CS 在校硕士三剑客之一：MCS（通用 CS）/ MDS（数据科学）/ MAI（AI 工程）；均为在校全日制。官网页未列截止/语言/GRE/学费，整项待补；与 Online MCS / Online MDS 在线版区分，本页仅录在校 MAI。"
)))

# 2. UNC CS MS
pages.append(("details/unc-cs-ms.html", build(
    title="计算机科学硕士（MS in Computer Science） | 北卡教堂山",
    crumb="北卡教堂山 UNC-Chapel Hill / 计算机科学硕士（MS in Computer Science）",
    h1="计算机科学硕士（MS in Computer Science）",
    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">全日制；研究/实践型硕士；Department of CS</span>',
    dept="Department of Computer Science",
    url="https://catalog.unc.edu/graduate/schools-departments/computer-science/",
    ddl="catalog 页未列具体轮次（待补）",
    lang="TOEFL iBT / IELTS Academic（最低分待补）",
    test="catalog 页未列（待补）",
    tui="catalog 页未列打包学费（待补）",
    core="<li>MS 课程面向真实计算机系统设计与应用、支撑实践的理论</li><li>系所约 150 名研究生，多数全日制</li><li>毕业生活跃于行业（初创公司、政府实验室、大型研发 corp）</li>",
    elect="<li>研究方向：生物信息与计算生物学、云计算、计算机架构、计算机图形、CSCW、计算机视觉、信息物理系统、数据科学、深度学习、几何计算、高性能计算、HCI、机器学习、医学图像分析、NLP、网络、实时系统、机器人、安全、软件工程、理论</li>",
    note="UNC CS 系成立于 1964 年，全美第二所独立 CS 系；catalog 页未列具体学分/课程列表/截止/语言/GRE/学费，整项待补。本页为 UNC catalog 官方口径，半核验页。"
)))

# 3. UNC DS MS (SDIS 在校版)
pages.append(("details/unc-ds-ms.html", build(
    title="数据科学硕士（MS in Data Science） | 北卡教堂山",
    crumb="北卡教堂山 UNC-Chapel Hill / 数据科学硕士（MS in Data Science）",
    h1="数据科学硕士（MS in Data Science）",
    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">全日制；School of Data and Information Sciences</span>',
    dept="School of Data and Information Sciences (SDIS)，2026 年由 SILS（1931）+ School of Data Science and Society（2022）合并",
    url="https://catalog.unc.edu/graduate/schools-departments/data-information-sciences/",
    ddl="catalog 页未列具体轮次（待补）",
    lang="TOEFL iBT / IELTS Academic（最低分待补）",
    test="catalog 页未列（待补）",
    tui="catalog 页未列打包学费（待补）",
    core="<li>MS in Data Science 在校研究型硕士</li><li>课程前缀：DATA（Data Science and Society）、INLS（Information and Library Science）、CHIP（Carolina Health Informatics Program）</li><li>强调人本位、伦理与应用的数据科学方法</li>",
    elect="<li>隶属 Carolina Health Informatics Program（CHIP）与 Center for Information, Technology and Public Life（CITAP）</li><li>方向：数据科学方法论、信息与图书馆学、健康信息学、计算与统计方法、社会应用</li>",
    note="SDIS 学院同时提供 Master of Applied Data Science（MADS）：在线 live + 异步 + in-person immersion，面向在职专业人士，按排除口径暂不录入；本页仅录在校 MS in Data Science。catalog 页未列学分/课程列表/截止/语言/GRE/学费，整项待补。"
)))

# 4. UNC BME MS (Lampe 联合)
pages.append(("details/unc-bme-ms.html", build(
    title="生物医学工程硕士（MS in Biomedical Engineering） | 北卡教堂山",
    crumb="北卡教堂山 UNC-Chapel Hill / 生物医学工程硕士（MS in Biomedical Engineering）",
    h1="生物医学工程硕士（MS in Biomedical Engineering）",
    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">UNC×NC State 联合 Lampe 系；GRE 不要求</span>',
    dept="Lampe Joint Department of Biomedical Engineering（UNC-Chapel Hill 与 NC State University 联合）",
    url="https://catalog.unc.edu/graduate/schools-departments/biomedical-engineering/",
    ddl="通常 12 月 12 日前提交秋季入学申请（catalog 页口径）",
    lang="TOEFL iBT / IELTS Academic（最低分待补）",
    test="GRE 不要求（Students are no longer required to submit GRE scores）",
    tui="catalog 页未列打包学费（待补）",
    core="<li>入学背景：工程、物理科学、数学或生物科学</li><li>课程：统计、数学、生命科学与工程交叉</li><li>研究训练含硕士阶段课题；与 Research Triangle Institute 及三角区产业界密切合作</li>",
    elect="<li>五大研究方向：康复工程（rehabilitation engineering）、再生医学（regenerative medicine）、生物医学成像（biomedical imaging）、生物医学微器件（biomedical microdevices）、药剂工程（pharmacoengineering）</li><li>录取画像：累计 GPA 约 3.30（B 等或以上），鼓励本科科研经历，需 1–3 页个人陈述（研究兴趣与背景），数学至少修到微分方程 + 两年物理/工程科学 + 生物基础课</li>",
    note="UNC×NC State 联合系，可申请任一校研究生院；录取画像为录取分布，非最低门槛。catalog 页未列学分/课程列表/语言/学费，整项待补。"
)))

# 5. UNC CRP MCRP
pages.append(("details/unc-mcrp.html", build(
    title="城市与区域规划硕士（Master of City and Regional Planning, MCRP） | 北卡教堂山",
    crumb="北卡教堂山 UNC-Chapel Hill / 城市与区域规划硕士（MCRP）",
    h1="城市与区域规划硕士（Master of City and Regional Planning, MCRP）",
    chips='<span class="chip">MCRP</span><span class="chip">北卡教堂山 UNC-Chapel Hill</span><span class="chip">soc</span><span class="chip">非 STEM（OPT 12 个月）</span><span class="chip">专业型规划硕士；Department of City and Regional Planning</span>',
    dept="Department of City and Regional Planning, College of Arts and Sciences",
    url="https://catalog.unc.edu/graduate/schools-departments/city-regional-planning/",
    ddl="catalog 页未列具体轮次（待补）",
    lang="TOEFL iBT / IELTS Academic（最低分待补）",
    test="catalog 页未列（待补）",
    tui="catalog 页未列打包学费（待补）",
    core="<li>Professional Master's Degree：面向职业规划实践</li><li>课程覆盖社会与制度问题、规划方法、公共政策研究、管理技能</li><li>跨学科：城市与区域预测、发展类型与区位、交通系统、经济发展、环境保护、利益协调、社区更新</li>",
    elect="<li>就业面：公共部门（地方/州/联邦政府）、非营利组织（国家/州/地方倡导团体）、私营部门（开发公司、咨询公司）</li><li>校内机会：TRUNC（Transportation Research @ UNC）、Community Engagement Laboratory（CEL）</li><li>系所历史悠久，校友网络遍布全球</li>",
    note="MCRP 为专业型规划硕士，与博士规划项目为不同学位；catalog 页未列学分/课程列表/截止/语言/GRE/学费，整项待补。"
)))

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

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