import re 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() body_match = re.search(r']*>(.*?)', html, re.IGNORECASE | re.DOTALL) content = body_match.group(1) if body_match else html # Remove header and footer content = re.sub(r'', '', content, flags=re.IGNORECASE | re.DOTALL) content = re.sub(r'', '', content, flags=re.IGNORECASE | re.DOTALL) # Swiper 1: Gallery # Find: (or similar) # Since the original HTML doesn't have plugin classes, let's look for btn-navigation-cap-chung-chi-prev # Wait, the first swiper has `swiper-pagination-training-gallery`. # Its container is `
` containing it. # Let's replace the whole block by splitting. def replace_block(text, marker, replacement): # Find the block containing the marker parts = text.split(marker) if len(parts) > 1: before = parts[0] # backtrack to the nearest