import { firefox } from 'playwright'; import { getRandomProxy } from './src/utils/proxyManager.js'; async function testBrandsPage() { const proxy = await getRandomProxy(); if (!proxy) { console.log('āŒ No proxy available'); process.exit(1); } console.log(`šŸ” Using proxy: ${proxy.server}`); const browser = await firefox.launch({ headless: true }); 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/131.0.0.0 Safari/537.36', proxy: { server: proxy.server, username: proxy.username, password: proxy.password } }); const page = await context.newPage(); try { console.log('šŸ“ Loading brands page...'); await page.goto('https://dutchie.com/embedded-menu/AZ-Deeply-Rooted/brands', { waitUntil: 'domcontentloaded', timeout: 45000 }); await page.waitForTimeout(5000); // Try to find brand elements const brandData = await page.evaluate(() => { // Look for various brand-related selectors const brandLinks = Array.from(document.querySelectorAll('a[href*="/brands/"], a[href*="/brand/"]')); const allLinks = Array.from(document.querySelectorAll('a')); const bodyText = document.body.textContent || ''; return { brandLinkCount: brandLinks.length, brandLinks: brandLinks.slice(0, 30).map(a => ({ href: a.getAttribute('href'), text: a.textContent?.trim().substring(0, 100) })), totalLinks: allLinks.length, pageTitle: document.title, bodyTextPreview: bodyText.substring(0, 500) }; }); console.log('\nšŸ“Š Brands Page Analysis:'); console.log(` Title: ${brandData.pageTitle}`); console.log(` Total links: ${brandData.totalLinks}`); console.log(` Brand links found: ${brandData.brandLinkCount}`); console.log(`\n Sample brand links:`); brandData.brandLinks.forEach((link, i) => { console.log(` ${i + 1}. ${link.text} -> ${link.href}`); }); console.log(`\n Page text preview:\n${brandData.bodyTextPreview}`); // Take a screenshot for debugging await page.screenshot({ path: '/tmp/brands-page.png', fullPage: true }); console.log('\nšŸ“ø Screenshot saved to /tmp/brands-page.png'); } catch (error: any) { console.error('āŒ Error:', error.message); } finally { await browser.close(); } } testBrandsPage();