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

# 删除我刚才误新建的占位文件
for p in ["details/ut-maccfin.html","details/ut-march.html","details/ut-imm-msc.html","details/ut-mirhr.html"]:
    if os.path.exists(p):
        os.remove(p); print("removed", p)

tpl = open("details/ut-c54a210.html", encoding="utf-8").read()

def build(page_title, h1, intro, facts, req, notes):
    facts_html = "".join(f'<div class="fact"><div class="fact-label">{l}</div><div class="fact-value">{v}</div></div>' for l,v in facts)
    req_html = "".join(f"<li>{r}</li>" for r in req)
    note_html = "".join(f"<li>{n}</li>" for n in notes)
    out = tpl
    out = out.replace("UToronto | MASc Mechanical & Industrial Engineering", page_title)
    out = re.sub(r"<h1[^>]*>.*?</h1>", f"<h1>{h1}</h1>", out, count=1, flags=re.S)
    out = re.sub(r'<div class="intro">.*?</div>', f'<div class="intro">{intro}</div>', out, count=1, flags=re.S|re.I)
    out = re.sub(r'<div class="facts">.*?</div>', f'<div class="facts">{facts_html}</div>', out, count=1, flags=re.S|re.I)
    out = re.sub(r'<ul class="req">.*?</ul>', f'<ul class="req">{req_html}</ul>', out, count=1, flags=re.S|re.I)
    out = re.sub(r'<ul class="notes">.*?</ul>', f'<ul class="notes">{note_html}</ul>', out, count=1, flags=re.S|re.I)
    return out

pages=[]

# 1. MAccFin -> 覆盖已有占位 det ut-c6f566f.html
pages.append(("details/ut-c6f566f.html", build(
    "UToronto | MAccFin Accounting & Finance",
    "多伦多大学 会计与金融硕士 MAccFin（UTSC 士嘉堡校区）",
    "Master of Accounting and Finance (MAccFin) 为多伦多大学士嘉堡校区（UTSC）管理与会计专业开设的授课型专业硕士，融合会计核心与金融分析能力，为 CPA/Chartered Professional Accountant 与金融职业路径提供学术训练。",
    [("学校","多伦多大学 University of Toronto（UTSC 士嘉堡校区）"),
     ("学院","UTSC 管理与会计专业"),
     ("学位","MAccFin (Master of Accounting and Finance)"),
     ("学制/类型","授课型专业硕士（Professional Course-based）"),
     ("最低录取平均分","mid-B / 73% / 3.0（final year；录取分布，非最低门槛）"),
     ("标化要求","GRE/GMAT：N/A（SGS 项目页未要求）"),
     ("PhD 通道","无独立 PhD 通道（Quick Facts 仅列 MAccFin）"),
     ("导师机制","授课型专业硕士，无录取前导师机制"),
     ("项目官网","https://www.sgs.utoronto.ca/programs/accounting/")],
    ["UTSC MAccFin 项目；最低录取平均分 mid-B / 73% / 3.0（final year）",
     "GRE/GMAT N/A（SGS 项目页明确）",
     "授课型专业硕士，无 thesis 要求、无录取前导师机制",
     "Fall 入学；申请截止日期 SGS 项目页未列具体日期，待补",
     "最低语言分（TOEFL/IELTS）SGS 项目页未列具体小分，按 SGS 通用口径待补",
     "打包学费 SGS 项目页未列，待补"],
    ["半核验页：Quick Facts 来自 SGS 官方项目页（sgs.utoronto.ca/programs/accounting/）；",
     "申请截止日期 / 最低语言分 / 打包学费 SGS 项目页未公布，整项留空待补，不臆造；",
     "加拿大项目一律 stem:0（不申请 STEM OPT Extension）；",
     "录取分数为录取分布口径，非最低门槛。"]
)))

# 2. MArch -> 覆盖已有占位 det ut-c0ea97e.html（disc=art）
pages.append(("details/ut-c0ea97e.html", build(
    "UToronto | MArch Architecture",
    "多伦多大学 建筑学硕士 MArch（John H. Daniels 建筑学院）",
    "Master of Architecture (MArch) 为多伦多大学 John H. Daniels Faculty of Architecture, Landscape, and Design 开设的 NAAB 认证授课型专业建筑硕士，面向建筑学职业执照路径，提供设计 studio、技术与历史理论训练。",
    [("学校","多伦多大学 University of Toronto"),
     ("学院","John H. Daniels Faculty of Architecture, Landscape, and Design"),
     ("学位","MArch (Master of Architecture)"),
     ("学制/类型","授课型专业硕士（Professional Architecture Degree）"),
     ("最低录取平均分","Mid-B（录取分布，非最低门槛）"),
     ("Direct-entry PhD","NA（MArch 无本科直博通道）"),
     ("标化要求","GRE/GMAT：N/A（SGS 项目页明确）"),
     ("导师机制","NA（授课型专业硕士，无录取前导师机制）"),
     ("项目官网","https://www.sgs.utoronto.ca/programs/architecture/")],
    ["Daniels 建筑学院 MArch；最低录取平均分 Mid-B",
     "Direct-entry PhD：NA；导师机制：NA（授课型专业硕士，无 thesis/导师分配）",
     "GRE/GMAT N/A（SGS 项目页明确）",
     "须提交作品集（Portfolio）——建筑专业申请标准材料",
     "Fall 入学；申请截止日期 SGS 项目页未列具体日期，待补",
     "最低语言分（TOEFL/IELTS）SGS 项目页未列具体小分，待补",
     "打包学费 SGS 项目页未列，待补"],
    ["半核验页：Quick Facts 来自 SGS 官方项目页（sgs.utoronto.ca/programs/architecture/）；",
     "申请截止日期 / 最低语言分 / 打包学费 SGS 项目页未公布，整项留空待补，不臆造；",
     "加拿大项目一律 stem:0；",
     "录取分数为录取分布口径，非最低门槛。"]
)))

# 3. Immunology MSc -> 覆盖已有占位 det ut-cf0519a.html（disc=med）
pages.append(("details/ut-cf0519a.html", build(
    "UToronto | MSc Immunology",
    "多伦多大学 免疫学硕士 MSc（Department of Immunology）",
    "Master of Science in Immunology 为多伦多大学 Immunology 研究生院开设的研究型硕士，聚焦分子免疫学、免疫调控、感染与免疫、肿瘤免疫等方向，含 thesis 研究要求，可衔接 PhD。",
    [("学校","多伦多大学 University of Toronto"),
     ("学院","Department of Immunology（文理学院 A&S / 医学院附属）"),
     ("学位","MSc (Master of Science in Immunology)"),
     ("学制/类型","研究型硕士（Research-based, thesis）"),
     ("最低录取平均分","MSc：B+ average in final two years of study；PhD：B+ average in MSc degree；Direct-entry PhD：A- average in final two years（录取分布，非最低门槛）"),
     ("Direct-entry PhD","Yes（本科直博通道开放）"),
     ("标化要求","GRE/GMAT：N/A；要求英语能力测试（非英语母语本科）"),
     ("PhD 通道","有（MSc 可衔接 PhD；本科可直博）"),
     ("项目官网","https://www.sgs.utoronto.ca/programs/immunology/")],
    ["Immunology 系；MSc 最低 B+（final two years）",
     "PhD：B+ in MSc；Direct-entry PhD：A- in final two years",
     "Direct-entry PhD：Yes",
     "GRE/GMAT N/A；英语能力测试要求（非英语母语本科）",
     "Fall 入学；申请截止日期 SGS 项目页未列具体日期，待补",
     "导师机制（录取前/后）SGS 项目页 Quick Facts 未列，待补",
     "最低语言分（TOEFL/IELTS）SGS 项目页未列具体小分，待补",
     "打包学费 SGS 项目页未列，待补"],
    ["半核验页：Quick Facts 来自 SGS 官方项目页（sgs.utoronto.ca/programs/immunology/）；",
     "申请截止日期 / 导师机制 / 最低语言分 / 打包学费 SGS 项目页未公布，整项留空待补，不臆造；",
     "加拿大项目一律 stem:0；",
     "录取分数为录取分布口径，非最低门槛。"]
)))

# 4. MIRHR -> 覆盖已有占位 det ut-c3a91ad.html（disc=biz）
pages.append(("details/ut-c3a91ad.html", build(
    "UToronto | MIRHR Industrial Relations & HR",
    "多伦多大学 劳资关系与人力资源硕士 MIRHR（CIRHR）",
    "Master of Industrial Relations and Human Resources (MIRHR) 为多伦多大学 Centre for Industrial Relations and Human Resources (CIRHR) 开设的授课型专业硕士，聚焦雇佣关系、人力资源管理、劳动经济学、组织行为，为 HR/劳资关系/政策职业路径提供训练。",
    [("学校","多伦多大学 University of Toronto"),
     ("学院","Centre for Industrial Relations and Human Resources (CIRHR)，文理学院 A&S"),
     ("学位","MIRHR (Master of Industrial Relations and Human Resources)"),
     ("学制/类型","授课型专业硕士（Professional Course-based）"),
     ("最低录取平均分","MIRHR：B+ (77%)；PhD：B+ (77%)（录取分布，非最低门槛）"),
     ("Direct-entry PhD","Yes（本科 IR/HR  exceptional standing + quantitative skills 可直博，须补额外课程）"),
     ("标化要求","MIRHR：英语能力测试（SGS 通用）；PhD：GRE required；MIRHR 不要求 GRE/GMAT"),
     ("导师机制","PhD：After admission（Applicant 自行联系）"),
     ("项目官网","https://www.sgs.utoronto.ca/programs/industrial-relations-and-human-resources/")],
    ["CIRHR；MIRHR 最低 B+ (77%)",
     "Direct-entry PhD：Yes（本科 IR/HR  exceptional standing + quantitative/research ability，须补额外课程）",
     "MIRHR：英语能力测试（按 SGS 通用口径）；GRE/GMAT 不要求",
     "PhD：GRE required；导师 After admission（Applicant 自行联系）",
     "Fall 入学；申请截止日期 SGS 项目页未列具体日期，待补",
     "最低语言分（TOEFL/IELTS）SGS 项目页未列具体小分，待补",
     "打包学费 SGS 项目页未列，待补"],
    ["半核验页：Quick Facts 来自 SGS 官方项目页（sgs.utoronto.ca/programs/industrial-relations-and-human-resources/）；",
     "申请截止日期 / 最低语言分 / 打包学费 SGS 项目页未公布，整项留空待补，不臆造；",
     "加拿大项目一律 stem:0；",
     "录取分数为录取分布口径，非最低门槛。"]
)))

# 5. Pharmacology MSc -> 新建 det ut-pharm-msc2.html，需补 CATD
pages.append(("details/ut-pharm-msc2.html", build(
    "UToronto | MSc Pharmacology",
    "多伦多大学 药理学硕士 MSc（Department of Pharmacology & Toxicology）",
    "Master of Science in Pharmacology 为多伦多大学 Pharmacology and Toxicology 系开设的研究型硕士，聚焦药物作用机制、毒理学、临床药理学、神经药理学等方向，含 thesis 研究要求，须申请前自行联系导师。",
    [("学校","多伦多大学 University of Toronto"),
     ("学院","Department of Pharmacology & Toxicology（医学院）"),
     ("学位","MSc (Master of Science in Pharmacology)"),
     ("学制/类型","研究型硕士（Research-based, thesis）"),
     ("最低录取平均分","MSc：final-year average of at least B+；PhD：B+ in master's degree courses；Direct-entry PhD：A- in final-year average（录取分布，非最低门槛）"),
     ("Direct-entry PhD","Yes"),
     ("标化要求","GRE/GMAT：N/A（SGS 项目页明确）"),
     ("导师机制","Before admission（录取前由 Applicant 自行联系）；录取以导师确认为条件"),
     ("项目官网","https://www.sgs.utoronto.ca/programs/pharmacology/")],
    ["Pharmacology & Toxicology 系；MSc 最低 final-year B+",
     "PhD：B+ in master's courses；Direct-entry PhD：A- in final-year average",
     "Direct-entry PhD：Yes",
     "导师 Before admission（Applicant 自行联系）；录取以导师确认为条件",
     "GRE/GMAT N/A（SGS 项目页明确）",
     "Fall 入学；申请截止日期 SGS 项目页未列具体日期，待补",
     "最低语言分（TOEFL/IELTS）SGS 项目页未列具体小分，待补",
     "打包学费 SGS 项目页未列，待补"],
    ["半核验页：Quick Facts 来自 SGS 官方项目页（sgs.utoronto.ca/programs/pharmacology/）；",
     "注意：与已入库 ut-pharm-msc（Leslie Dan 药学院 Pharmaceutical Sciences MSc）为不同系项目，不重复；",
     "申请截止日期 / 最低语言分 / 打包学费 SGS 项目页未公布，整项留空待补，不臆造；",
     "加拿大项目一律 stem:0；",
     "录取分数为录取分布口径，非最低门槛。"]
)))

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