Files
cannaiq/backend/check-for-prices.ts
2025-11-28 19:45:44 -07:00

90 lines
2.6 KiB
TypeScript

import { firefox } from 'playwright';
import { getRandomProxy } from './src/utils/proxyManager.js';
async function checkForPrices() {
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(5000);
// Check for any dollar signs on the entire page
const pageText = await page.evaluate(() => document.body.textContent);
const hasDollarSigns = pageText?.includes('$');
console.log('\n' + '='.repeat(80));
console.log('PRICE AVAILABILITY CHECK:');
console.log('='.repeat(80));
console.log(`\nPage contains '$' symbol: ${hasDollarSigns ? 'YES' : 'NO'}`);
if (hasDollarSigns) {
// Find all text containing dollar signs
const priceElements = await page.evaluate(() => {
const walker = document.createTreeWalker(
document.body,
NodeFilter.SHOW_TEXT,
null
);
const results: string[] = [];
let node;
while (node = walker.nextNode()) {
const text = node.textContent?.trim();
if (text && text.includes('$')) {
results.push(text);
}
}
return results.slice(0, 10); // First 10 instances
});
console.log('\nText containing "$":');
priceElements.forEach((text, idx) => {
console.log(` ${idx + 1}. ${text.substring(0, 100)}`);
});
}
// Check specifically within product cards
const productCardPrices = await page.evaluate(() => {
const cards = Array.from(document.querySelectorAll('a[href*="/product/"]'));
return cards.slice(0, 5).map(card => ({
text: card.textContent?.substring(0, 200),
hasDollar: card.textContent?.includes('$') || false
}));
});
console.log('\nFirst 5 Product Cards:');
productCardPrices.forEach((card, idx) => {
console.log(`\n Card ${idx + 1}:`);
console.log(` Has $: ${card.hasDollar}`);
console.log(` Text: ${card.text}`);
});
console.log('\n' + '='.repeat(80));
await browser.close();
process.exit(0);
}
checkForPrices().catch(console.error);