# -*- coding: utf-8 -*-
"""从 dump 的 dom 里取出 id="E2E" 节点的文本，写 utf-8 文件"""
import io, sys, html as H

src = sys.argv[1] if len(sys.argv) > 1 else r'D:\workbbbbbb\build\_tt_dom.html'
dst = sys.argv[2] if len(sys.argv) > 2 else r'D:\workbbbbbb\build\_tt_out.txt'

with io.open(src, 'r', encoding='utf-8', errors='replace') as f:
    s = f.read()

i = s.find('id="E2E"')
if i < 0:
    txt = 'NO_E2E'
else:
    j = s.find('>', i)
    k = s.find('</div>', j)
    txt = H.unescape(s[j + 1:k])

with io.open(dst, 'w', encoding='utf-8') as f:
    f.write(txt)
print('len', len(txt))
