Files
sisvietnamvn_01/.temp/parse_html_full.py
T

27 lines
1.0 KiB
Python

import re
import json
with open('/home/x79/sisvietnamvn_01/sisvietnamvn_Trang chính thức hiện tại/Đào tạo tại UMC.html', 'r', encoding='utf-8') as f:
html = f.read()
# 1. Extract <body> content
body_match = re.search(r'<body[^>]*>(.*?)</body>', html, re.IGNORECASE | re.DOTALL)
if body_match:
body_content = body_match.group(1)
else:
body_content = html
# We will replace the whole div that contains the swiper.
# Looking at standard Swiper HTML:
# <div class="relative md:flex md:items-center md:gap-x-2..."> ... </div>
# or something similar.
# Since we just want to replace the Swiper Sliders, let's find the container block.
# Actually, the user has 4 Swiper Sliders. We can just find the `<div class="swiper swiper-initialized ..."` and replace its parent block.
# To be safe, let's just find the `swiper` divs and extract their data.
slides_data = []
# This is a bit complex without BeautifulSoup. I'll just use a basic string split approach.
parts = html.split('class="swiper swiper-initialized')
print(f"Found {len(parts)} parts")