import re with open('main_extracted.html', 'r', encoding='utf-8') as f: html = f.read() # Clean up unwanted tags html = re.sub(r'', '', html, flags=re.DOTALL) html = re.sub(r'', '', html, flags=re.DOTALL) html = re.sub(r'
', '', html, flags=re.DOTALL) # simple regex might fail on nested divs, but let's try # better to just strip specific known script tags html = re.sub(r'
', '', html, flags=re.DOTALL) # replace _next/image paths html = re.sub(r'/_next/image\?url=(.*?)&.*?(?: |"|\')', r'\1"', html) # URL decode the paths (simple replacement) html = html.replace('%2F', '/') # wrap in Thymeleaf template = f""" Đội ngũ bác sĩ | UMC
{html}
""" with open('src/main/resources/templates/doctor.html', 'w', encoding='utf-8') as f: f.write(template) print("Generated src/main/resources/templates/doctor.html")