import re import sys with open('templates/backtest.html', 'r', encoding='utf-8') as f: content = f.read() # The block starts with
and ends after the table and its div. # We'll use regex to grab it precisely by searching for the "최근 잡" header. start_idx = content.find('
\n
\n
최근 잡') if start_idx == -1: print("Could not find start of block") sys.exit(1) # Find the end of the block (the closing div of the card) end_str = ' \n
\n
\n' end_idx = content.find(end_str, start_idx) if end_idx == -1: print("Could not find end of block") sys.exit(1) end_idx += len(end_str) block = content[start_idx:end_idx] # Remove the block from the original location content = content[:start_idx] + content[end_idx:] # Find the insertion point: right after