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>
This commit is contained in:
68
backend/archive/scrape-azdhs-map.ts
Normal file
68
backend/archive/scrape-azdhs-map.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { chromium } from 'playwright-extra';
|
||||
import stealth from 'puppeteer-extra-plugin-stealth';
|
||||
import { pool } from './src/db/migrate';
|
||||
|
||||
chromium.use(stealth());
|
||||
|
||||
async function scrapeAZDHSMap() {
|
||||
console.log('🏛️ Scraping official AZDHS Arizona dispensary map...\n');
|
||||
|
||||
const browser = await chromium.launch({
|
||||
headless: false,
|
||||
});
|
||||
|
||||
const context = await browser.newContext({
|
||||
viewport: { width: 1920, height: 1080 },
|
||||
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
||||
});
|
||||
|
||||
const page = await context.newPage();
|
||||
|
||||
try {
|
||||
console.log('📄 Loading AZDHS map page...');
|
||||
|
||||
await page.goto('https://azcarecheck.azdhs.gov/s/?facilityId=001t000000L0TApAAN', {
|
||||
waitUntil: 'networkidle',
|
||||
timeout: 60000
|
||||
});
|
||||
|
||||
// Wait for page to fully load
|
||||
await page.waitForTimeout(10000);
|
||||
|
||||
console.log('🔍 Extracting dispensary data...\n');
|
||||
|
||||
// Extract all dispensary data
|
||||
const dispensaries = await page.evaluate(() => {
|
||||
const results: any[] = [];
|
||||
|
||||
// This is a Salesforce Community page - look for the data
|
||||
// Check window object
|
||||
const windowKeys = Object.keys(window);
|
||||
console.log('Window keys sample:', windowKeys.filter(k => k.includes('SF') || k.includes('data') || k.includes('facility')).slice(0, 20));
|
||||
|
||||
// Try to find all facility/location markers or data
|
||||
// Look for common patterns in Salesforce maps
|
||||
const facilityElements = document.querySelectorAll('[class*="facility"], [class*="location"], [class*="marker"]');
|
||||
console.log('Found facility elements:', facilityElements.length);
|
||||
|
||||
return {
|
||||
debug: 'AZDHS page',
|
||||
windowKeysCount: windowKeys.length,
|
||||
facilityElements: facilityElements.length,
|
||||
sampleHTML: document.body.innerHTML.substring(0, 2000)
|
||||
};
|
||||
});
|
||||
|
||||
console.log('Debug info:');
|
||||
console.log(JSON.stringify(dispensaries, null, 2).substring(0, 1500));
|
||||
|
||||
} catch (error) {
|
||||
console.error(`❌ Error: ${error}`);
|
||||
throw error;
|
||||
} finally {
|
||||
await browser.close();
|
||||
await pool.end();
|
||||
}
|
||||
}
|
||||
|
||||
scrapeAZDHSMap();
|
||||
Reference in New Issue
Block a user