import re
with open('index_main.html','r',encoding='utf-8') as f:
    html = f.read()
# 找 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  # just after ]
print(f'PROGRAMS array ends at position {prog_end}')
# 看 PROGRAMS 最后500字符
print('--- PROGRAMS last 600 chars ---')
print(html[prog_end-600:prog_end+100])
