import re
from bs4 import BeautifulSoup

with open('pedagogy_html.txt', 'r') as f:
    html = f.read()

soup = BeautifulSoup(html, 'html.parser')

# Find the start point "UNIQUE PEDAGOGY"
sections = soup.find_all('section')
target_sections = []
recording = False

for sec in sections:
    text = sec.get_text()
    if 'UNIQUE PEDAGOGY' in text and not recording:
        recording = True
    
    if recording:
        target_sections.append(str(sec))
    
    if 'Book a free Counselling' in text:
        break

print("FOUND SECTIONS:", len(target_sections))
# Write to a cleaner file
with open('extracted.html', 'w') as out:
    out.write("\n\n".join(target_sections))
