40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
import re
|
|
|
|
with open('main_extracted.html', 'r', encoding='utf-8') as f:
|
|
html = f.read()
|
|
|
|
# Clean up unwanted tags
|
|
html = re.sub(r'<script.*?</script>', '', html, flags=re.DOTALL)
|
|
html = re.sub(r'<next-route-announcer.*?</next-route-announcer>', '', html, flags=re.DOTALL)
|
|
html = re.sub(r'<div id="easychatgpt-widget".*?</template></div>', '', 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'<div id="easychatgpt-widget".*?</div></div></div></div></div>', '', 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"""<!DOCTYPE html>
|
|
<html lang="vi" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
layout:decorate="~{{fragments/layout}}">
|
|
|
|
<head>
|
|
<th:block layout:fragment="head">
|
|
<title>Đội ngũ bác sĩ | UMC</title>
|
|
</th:block>
|
|
</head>
|
|
<body>
|
|
<div layout:fragment="content">
|
|
{html}
|
|
</div>
|
|
</body>
|
|
</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")
|