20 lines
613 B
Python
20 lines
613 B
Python
import re
|
|
|
|
with open('fix_home_block1.html', 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
with open('block1_html.html', 'r', encoding='utf-8') as f:
|
|
new_html = f.read()
|
|
|
|
pattern_hero = re.compile(r'<div class="kmc-landing">
|
|
*<section class="kmc-hero">.*?</section>', re.DOTALL)
|
|
|
|
if pattern_hero.search(content):
|
|
content = pattern_hero.sub('<div class="kmc-landing">
|
|
' + new_html + '\n', content, count=1)
|
|
|
|
with open('tmp_home_updated_block1.html', 'w', encoding='utf-8') as f:
|
|
f.write(content)
|
|
print("Replaced successfully!")
|
|
else:
|
|
print("Could not find kmc-hero section") |