import re
with open('index_main.html','r',encoding='utf-8') as f:
    html = f.read()
# 找新 VD 字符串在文件中的位置
for nid in ['gatech-ae-phd','stanford-me-phd','berkeley-me-phd','notre-ame-phd','ucla-mae-phd']:
    needle = 'details/'+nid+'.html'
    positions = [m.start() for m in re.finditer(re.escape(needle), html)]
    print(f'{nid}: positions={positions}')
# 找 PROGRAMS 结束位置
m = re.search(r'const\s+PROGRAMS\s*=\s*\[', html)
start = m.end()
depth = 1
i = start
while i < len(html) and depth > 0:
    c = html[i]
    if c == '[': depth += 1
    elif c == ']': depth -= 1
    i += 1
prog_end = i
print(f'PROGRAMS ends at {prog_end}')
# 找 VD 开始
m2 = re.search(r'VERIFIED_DETAILS\s*=\s*new\s+Set\s*\(\s*\[', html)
print(f'VERIFIED_DETAILS starts at {m2.start()}')
# 看 prog_end 到 VD start 之间的内容
mid = html[prog_end:m2.start()]
print(f'--- Between PROGRAMS end and VD start (length {len(mid)}) ---')
print(mid[:2000])
