Files
cannaiq/backend/debug-product-card.ts
2025-11-28 19:45:44 -07:00

57 lines
1.6 KiB
TypeScript

import { firefox } from 'playwright';
import { getRandomProxy } from './src/utils/proxyManager.js';
async function debugProductCard() {
const proxy = await getRandomProxy();
if (!proxy) {
console.log('No proxy available');
process.exit(1);
}
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',
proxy: {
server: proxy.server,
username: proxy.username,
password: proxy.password
}
});
const page = await context.newPage();
const brandUrl = 'https://dutchie.com/embedded-menu/AZ-Deeply-Rooted/brands/alien-labs';
console.log(`Loading: ${brandUrl}`);
await page.goto(brandUrl, { waitUntil: 'domcontentloaded', timeout: 60000 });
await page.waitForTimeout(3000);
// Get the first product card's full text content
const cardData = await page.evaluate(() => {
const card = document.querySelector('a[href*="/product/"]');
if (!card) return null;
return {
href: card.getAttribute('href'),
innerHTML: card.innerHTML.substring(0, 2000),
textContent: card.textContent?.substring(0, 1000)
};
});
console.log('\n' + '='.repeat(80));
console.log('FIRST PRODUCT CARD DATA:');
console.log('='.repeat(80));
console.log('\nHREF:', cardData?.href);
console.log('\nTEXT CONTENT:');
console.log(cardData?.textContent);
console.log('\nHTML (first 2000 chars):');
console.log(cardData?.innerHTML);
console.log('='.repeat(80));
await browser.close();
process.exit(0);
}
debugProductCard().catch(console.error);