path = '/home/x79/sisvietnamvn_01/sisvietnamvn_main/src/main/resources/templates/dao-tao-detail.html' with open(path, 'r', encoding='utf-8') as f: content = f.read() def clean_style(text): start = 0 while True: idx = text.find(' style="', start) if idx == -1: idx = text.find(" style='", start) if idx == -1: break quote = text[idx + 7] end_idx = text.find(quote, idx + 8) if end_idx == -1: break style_content = text[idx+8:end_idx] if "animation-composition" in style_content: text = text[:idx] + text[end_idx+1:] else: start = end_idx + 1 return text new_content = clean_style(content) with open(path, 'w', encoding='utf-8') as f: f.write(new_content) print("Cleaned HTML!")