import os import re files = ['kemiskinan.html', 'spbu.html', 'jalan.html', 'persil.html'] for file in files: with open(file, 'r', encoding='utf-8') as f: content = f.read() # 1. Remove nav-tabs block # Use regex to find and remove the div with class="nav-tabs" and its contents nav_tabs_pattern = re.compile(r'', re.DOTALL) content = nav_tabs_pattern.sub('', content) # 2. Add back button in panel-head panel_head_str = '
\n

' back_btn_html = '''
Kembali ke Beranda

''' # Only replace if not already replaced if 'Kembali ke Beranda' not in content: content = content.replace(panel_head_str, back_btn_html) with open(file, 'w', encoding='utf-8') as f: f.write(content)