Files
sisvietnamvn_01/sisvietnamvn_main/parse_index.py
T

44 lines
1.4 KiB
Python

import re
import sys
def main():
try:
with open('src/main/resources/templates/index.html', 'r', encoding='utf-8') as f:
lines = f.readlines()
content_top_start = -1
for i, line in enumerate(lines):
if '<div class="content-top">' in line:
content_top_start = i
break
# The next block starts with '<div class="lc--layout-container lc--full">'
# But content-top itself has one.
# Let's search for the second '<div class="lc--layout-container lc--full">'
next_block_start = -1
count = 0
for i in range(content_top_start, len(lines)):
if '<div class="lc--layout-container lc--full">' in lines[i]:
count += 1
if count == 2:
next_block_start = i
break
end_of_file_content = -1
for i in range(len(lines)-1, -1, -1):
if '<footer th:replace' in lines[i]:
# Go up to the closing tags of t--template
end_of_file_content = i - 5
break
print(f"Content top start: {content_top_start}")
print(f"Next block start: {next_block_start}")
print(f"End of content: {end_of_file_content}")
except Exception as e:
print(e)
if __name__ == '__main__':
main()