from docx import Document
import os

doc = Document()
doc.add_heading('David Labs and Scans - Site Delivery', 0)

doc.add_heading('1. Complete Live URL Directory', level=1)
p = doc.add_paragraph('Main Hub Page: ')
p.add_run('https://www.davidscans.com/speciality.html').bold = True

locations = [
    ('Porur', 'porur'), ('Kundrathur', 'kundrathur'), ('Gerugambakkam', 'gerugambakkam'),
    ('Ramapuram', 'ramapuram'), ('Iyyappanthangal', 'iyyappanthangal'), ('Mugalivakkam', 'mugalivakkam'),
    ('Kolapakkam', 'kolapakkam'), ('Anakaputhur', 'anakaputhur'), ('Thiruverkadu', 'thiruverkadu'),
    ('Kattupakkam', 'kattupakkam'), ('Maduravoyal', 'maduravoyal')
]

services = [
    'ultrasound-scan', 'blood-test', 'digital-x-ray', 'pregnancy-scan', 'cardiac-package',
    'ecg', 'echo', 'pft', 'allergy-test', 'preventive-health-checkup'
]

for loc_name, loc_slug in locations:
    doc.add_heading(f'Location: {loc_name}', level=2)
    urls = []
    for srv in services:
        urls.append(f"https://www.davidscans.com/speciality/{loc_slug}/{srv}.html")
    doc.add_paragraph("\n".join(urls))

doc.add_page_break()

doc.add_heading('2. Full Live Text Content Dump', level=1)

with open('ALL_PAGES_CONTENT.txt', 'r', encoding='utf-8') as f:
    text_content = f.read()

# Split the dump into chunks to ensure word formats properly
for line in text_content.split('\n'):
    if line.strip():
        doc.add_paragraph(line.strip())
    else:
        doc.add_paragraph("") # empty line

doc.save('David_Scans_Complete_Website_Content.docx')
print("Successfully generated Word document!")
