67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
import { chromium } from 'playwright';
|
|
|
|
async function main() {
|
|
console.log('Launching browser...');
|
|
const browser = await chromium.launch({ headless: true });
|
|
const context = await browser.newContext({
|
|
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
|
|
});
|
|
|
|
const page = await context.newPage();
|
|
|
|
try {
|
|
console.log('Navigating to BEST Dispensary Treez menu...');
|
|
await page.goto('https://best.treez.io/onlinemenu/?customerType=ADULT', {
|
|
waitUntil: 'networkidle',
|
|
timeout: 30000
|
|
});
|
|
|
|
console.log('Waiting for content to load...');
|
|
await page.waitForTimeout(5000);
|
|
|
|
// Check for products
|
|
console.log('\n=== Looking for product containers ===');
|
|
const productSelectors = [
|
|
'.product',
|
|
'.product-card',
|
|
'[class*="product"]',
|
|
'[class*="Product"]',
|
|
'[data-product]',
|
|
'.item',
|
|
'.menu-item'
|
|
];
|
|
|
|
for (const selector of productSelectors) {
|
|
const count = await page.locator(selector).count();
|
|
if (count > 0) {
|
|
console.log(`Found ${count} elements matching: ${selector}`);
|
|
|
|
// Get first element's HTML
|
|
const html = await page.locator(selector).first().innerHTML();
|
|
console.log(`\nFirst element HTML (truncated):`);
|
|
console.log(html.substring(0, 500));
|
|
}
|
|
}
|
|
|
|
// Get page title and first 1000 chars of body
|
|
const title = await page.title();
|
|
const bodyText = await page.locator('body').textContent();
|
|
|
|
console.log(`\n=== Page Info ===`);
|
|
console.log(`Title: ${title}`);
|
|
console.log(`\nBody text (first 1000 chars):`);
|
|
console.log(bodyText?.substring(0, 1000));
|
|
|
|
// Check for any links
|
|
const links = await page.locator('a').count();
|
|
console.log(`\nTotal links: ${links}`);
|
|
|
|
} catch (error: any) {
|
|
console.error('Error:', error.message);
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
}
|
|
|
|
main().catch(console.error);
|