#!/usr/bin/env python3
"""Debug: check where phone numbers are in the DOM."""
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(
        headless=True,
        args=["--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage", "--disable-gpu"]
    )
    page = browser.new_page(
        viewport={"width": 1920, "height": 1080},
        user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36",
        locale="en-IN",
        timezone_id="Asia/Kolkata",
    )
    
    page.goto("https://www.google.com/maps/search/interior+designers+in+Hayathnagar/", timeout=30000)
    page.wait_for_timeout(8000)
    
    for _ in range(3):
        page.evaluate("document.querySelector('[role=\"feed\"]')?.scrollBy(0, 1000)")
        page.wait_for_timeout(2000)
    
    # Check the first article element's full HTML
    html = page.evaluate("""
        () => {
            const feed = document.querySelector('[role="feed"]');
            if (!feed) return 'No feed';
            
            const articles = feed.querySelectorAll('[role="article"]');
            if (!articles.length) return 'No articles';
            
            // Get the full outer HTML of first article
            const first = articles[0];
            return {
                outerHTML: first.outerHTML.substring(500, 3000),
                innerText: first.innerText.substring(0, 1500),
            };
        }
    """)
    
    print("=== innerText ===")
    print(html.get('innerText', '')[:1000])
    
    browser.close()
