import { chromium } from 'playwright-extra'; import stealth from 'puppeteer-extra-plugin-stealth'; import { pool } from './src/db/migrate'; chromium.use(stealth()); async function debugAZDHSPage() { console.log('šŸ” Debugging AZDHS page structure...\n'); const browser = await chromium.launch({ headless: false, }); const context = await browser.newContext({ viewport: { width: 1920, height: 1080 }, }); const page = await context.newPage(); try { console.log('šŸ“„ Loading page...'); await page.goto('https://azcarecheck.azdhs.gov/s/?facilityId=001t000000L0TApAAN', { waitUntil: 'domcontentloaded', timeout: 60000 }); console.log('ā³ Waiting 30 seconds for you to scroll and load all dispensaries...\n'); await page.waitForTimeout(30000); console.log('šŸ” Analyzing page structure...\n'); const debug = await page.evaluate(() => { // Get all unique tag names const allElements = document.querySelectorAll('*'); const tagCounts: any = {}; const classSamples: string[] = []; allElements.forEach(el => { const tag = el.tagName.toLowerCase(); tagCounts[tag] = (tagCounts[tag] || 0) + 1; // Sample some classes if (el.className && typeof el.className === 'string' && el.className.length > 0 && classSamples.length < 50) { classSamples.push(el.className.substring(0, 80)); } }); // Look for elements with text that might be dispensary names const textElements: any[] = []; allElements.forEach(el => { const text = el.textContent?.trim() || ''; if (text.length > 10 && text.length < 200 && el.children.length < 5) { textElements.push({ tag: el.tagName.toLowerCase(), class: el.className ? el.className.substring(0, 50) : '', text: text.substring(0, 100) }); } }); return { totalElements: allElements.length, tagCounts: Object.entries(tagCounts).sort((a: any, b: any) => b[1] - a[1]).slice(0, 20), classSamples: classSamples.slice(0, 20), textElementsSample: textElements.slice(0, 10) }; }); console.log('šŸ“Š Page Structure Analysis:'); console.log(`\nTotal elements: ${debug.totalElements}`); console.log('\nTop 20 element types:'); console.table(debug.tagCounts); console.log('\nSample classes:'); debug.classSamples.forEach((c: string, i: number) => console.log(` ${i + 1}. ${c}`)); console.log('\nSample text elements (potential dispensary names):'); console.table(debug.textElementsSample); } catch (error) { console.error(`āŒ Error: ${error}`); } finally { console.log('\nšŸ‘‰ Browser will stay open for 30 seconds so you can inspect...'); await page.waitForTimeout(30000); await browser.close(); await pool.end(); } } debugAZDHSPage();