import re
html = open('index_main.html', encoding='utf-8').read()
# Find all positions of id:"usc-mmi-ms"
for m in re.finditer(r'id:"usc-mmi-ms"', html):
    pos = m.start()
    # find surrounding { ... }
    start = html.rfind('{', 0, pos)
    # find matching close brace
    depth = 0
    i = start
    while i < len(html):
        c = html[i]
        if c == '{':
            depth += 1
        elif c == '}':
            depth -= 1
            if depth == 0:
                end = i + 1
                break
        i += 1
    print('pos', pos, 'span', start, end)
    print(html[start:end])
    print('---')
