import { scrapeCategoryPlaywright } from './src/services/scraper-playwright'; import { pool } from './src/db/migrate'; import { getRandomProxy, getStateProxy, getProxyLocationStats } from './src/utils/proxyManager'; async function testStealthScraper() { console.log('๐Ÿงช Testing stealth scraper on Sol Flower Sun City\n'); const categoryUrl = 'https://dutchie.com/dispensary/sol-flower-dispensary/shop/flower'; const categoryName = 'Flower'; const state = 'Arizona'; console.log(`๐Ÿ“‚ Category: ${categoryName}`); console.log(`๐Ÿ”— URL: ${categoryUrl}`); console.log(`๐Ÿ“ State: ${state}\n`); try { // Show proxy location distribution console.log('๐Ÿ“Š Proxy location distribution:'); const stats = await getProxyLocationStats(); console.table(stats.slice(0, 10)); console.log(''); // Get an active residential proxy from database console.log('๐Ÿ” Fetching active residential proxy...'); const proxy = await getRandomProxy(); if (proxy) { console.log(`โœ… Using proxy: ${proxy.server}`); console.log(` Credentials: ${proxy.username ? 'Yes' : 'No'}\n`); } else { console.log('โš ๏ธ No active proxies found, proceeding without proxy\n'); } const products = await scrapeCategoryPlaywright(categoryUrl, categoryName, state, proxy); console.log(`\nโœ… Scrape completed!`); console.log(`๐Ÿ“ฆ Found ${products.length} products\n`); if (products.length > 0) { console.log('๐ŸŽ‰ SUCCESS! Cloudflare bypass worked!\n'); console.log('First 5 products:'); products.slice(0, 5).forEach((product, i) => { console.log(` ${i + 1}. ${product.name}`); if (product.brand) console.log(` Brand: ${product.brand}`); if (product.price) console.log(` Price: $${product.price}`); }); } else { console.log('โš ๏ธ No products found - may need more stealth adjustments'); } } catch (error) { console.error('โŒ Error:', error); } finally { await pool.end(); } } testStealthScraper();