Files
sisvietnamvn_01/sisvietnamvn_main/parse_html_no_bs4.py
T

22 lines
872 B
Python

import re
with open('/home/x79/sisvietnamvn_01/BV_DHYD_HCM/Đội ngũ bác sĩ UMC.html', 'r', encoding='utf-8') as f:
content = f.read()
# Try to find <main> tag
main_match = re.search(r'<main[^>]*>.*?</main>', content, flags=re.DOTALL | re.IGNORECASE)
if main_match:
main_html = main_match.group(0)
print(f"Found <main> tag! Size: {len(main_html)} bytes")
# Save it to a file for easier inspection
with open('main_extracted.html', 'w', encoding='utf-8') as out:
out.write(main_html)
print("Saved to main_extracted.html")
else:
print("No <main> tag found. Looking for #__next")
next_match = re.search(r'<div[^>]*id=["\']__next["\'][^>]*>.*?</div><!--', content, flags=re.DOTALL | re.IGNORECASE)
if next_match:
print("Found __next but regex might not match the whole nested div accurately without an HTML parser.")