Files
cannaiq/backend/archive/debug-azdhs-page.ts
Kelly d91c55a344 feat: Add stale process monitor, users route, landing page, archive old scripts
- Add backend stale process monitoring API (/api/stale-processes)
- Add users management route
- Add frontend landing page and stale process monitor UI on /scraper-tools
- Move old development scripts to backend/archive/
- Update frontend build with new features

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 04:07:31 -07:00

89 lines
2.8 KiB
TypeScript

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();