feat: implement swiper slider, tabbed livestream, and table extension plugins with schema updates for settings content
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
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()
|
||||
|
||||
parts = html.split('<div class="swiper-wrapper">')
|
||||
|
||||
groups = []
|
||||
slugs = ['gallery', 'chung-chi', 'giay-chung-nhan', 'xac-nhan-thuc-hanh', 'hinh-anh-thuc-hanh']
|
||||
names = ['Gallery Đào Tạo', 'Đào tạo cấp chứng chỉ', 'Đào tạo cấp giấy chứng nhận', 'Xác nhận quá trình thực hành', 'Hình ảnh thực hành']
|
||||
|
||||
for i in range(1, len(parts)):
|
||||
part = parts[i]
|
||||
slug = slugs[i-1] if (i-1) < len(slugs) else f"unknown-{i}"
|
||||
name = names[i-1] if (i-1) < len(names) else f"Unknown {i}"
|
||||
|
||||
# We only care about the slides for this swiper.
|
||||
# The swiper ends with `<div class="swiper-pagination` or `btn-navigation` or `</section>`
|
||||
# We can just extract all `<div class="swiper-slide` up to the end of the wrapper.
|
||||
# Since we can't easily parse DOM, we'll just extract all <img> tags inside `swiper-slide` that appear before the next wrapper.
|
||||
# Actually, we can split by `swiper-slide`
|
||||
|
||||
slides_html = part.split('class="swiper-slide')
|
||||
items = []
|
||||
|
||||
for j in range(1, len(slides_html)):
|
||||
slide = slides_html[j]
|
||||
# find image
|
||||
img_match = re.search(r'<img[^>]*src="([^"]+)"', slide)
|
||||
img_url = img_match.group(1) if img_match else ""
|
||||
|
||||
# find title - it's usually inside <h3...> or just alt text.
|
||||
# Let's check heading-5
|
||||
title_match = re.search(r'<h3[^>]*>(.*?)</h3>', slide, re.IGNORECASE | re.DOTALL)
|
||||
if title_match:
|
||||
title = re.sub(r'<[^>]+>', '', title_match.group(1)).strip()
|
||||
else:
|
||||
alt_match = re.search(r'<img[^>]*alt="([^"]*)"', slide)
|
||||
title = alt_match.group(1) if alt_match else ""
|
||||
|
||||
items.append({
|
||||
"title": title,
|
||||
"imageUrl": img_url,
|
||||
"linkUrl": "#",
|
||||
"description": ""
|
||||
})
|
||||
|
||||
# Filter empty
|
||||
items = [it for it in items if it['imageUrl']]
|
||||
|
||||
groups.append({
|
||||
"slug": slug,
|
||||
"name": name,
|
||||
"items": items
|
||||
})
|
||||
|
||||
print(json.dumps(groups, ensure_ascii=False))
|
||||
|
||||
Reference in New Issue
Block a user