import { scrapeCategoryPlaywright } from './src/services/scraper-playwright'; import { getRandomProxy } from './src/utils/proxyManager'; import { pool } from './src/db/migrate'; async function testTemplateIntegration() { console.log('๐Ÿงช Testing Dutchie template integration\n'); console.log('This test verifies that:'); console.log(' 1. The scraper detects Dutchie URLs'); console.log(' 2. The template is automatically used'); console.log(' 3. Products are extracted correctly\n'); const categoryUrl = 'https://dutchie.com/dispensary/sol-flower-dispensary/products/flower'; const categoryName = 'Flower'; const state = 'Arizona'; console.log(`๐Ÿ“‚ Category: ${categoryName}`); console.log(`๐Ÿ”— URL: ${categoryUrl}`); console.log(`๐Ÿ“ State: ${state}\n`); try { // Get proxy const proxy = await getRandomProxy(); if (proxy) { console.log(`๐Ÿ” Using proxy: ${proxy.server}\n`); } else { console.log('โš ๏ธ No proxy available, proceeding without proxy\n'); } console.log('๐ŸŽญ Starting scrape with template integration...\n'); const products = await scrapeCategoryPlaywright(categoryUrl, categoryName, state, proxy || undefined); console.log(`\nโœ… Scrape completed!`); console.log(`๐Ÿ“ฆ Found ${products.length} products\n`); if (products.length > 0) { console.log('๐ŸŽ‰ SUCCESS! Template integration working!\n'); console.log('First 10 products:'); products.slice(0, 10).forEach((product, i) => { console.log(`\n${i + 1}. ${product.name}`); if (product.brand) console.log(` Brand: ${product.brand}`); if (product.price) console.log(` Price: $${product.price}`); console.log(` URL: ${product.product_url}`); }); } else { console.log('โš ๏ธ No products found - integration may need debugging'); } } catch (error) { console.error('โŒ Error:', error); } finally { await pool.end(); } } testTemplateIntegration();