48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { chromium } from 'playwright';
|
|
|
|
const GOOGLE_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';
|
|
|
|
async function main() {
|
|
const browser = await chromium.launch({ headless: true });
|
|
const context = await browser.newContext({
|
|
userAgent: GOOGLE_UA
|
|
});
|
|
|
|
const page = await context.newPage();
|
|
|
|
try {
|
|
console.log('Loading menu page...');
|
|
await page.goto('https://best.treez.io/onlinemenu/?customerType=ADULT', {
|
|
waitUntil: 'networkidle',
|
|
timeout: 30000
|
|
});
|
|
|
|
await page.waitForTimeout(3000);
|
|
|
|
// Get first 3 menu items and inspect their HTML structure
|
|
const menuItems = await page.locator('.menu-item').all();
|
|
|
|
console.log(`\nFound ${menuItems.length} menu items. Inspecting first 3:\n`);
|
|
|
|
for (let i = 0; i < Math.min(3, menuItems.length); i++) {
|
|
const item = menuItems[i];
|
|
const html = await item.innerHTML();
|
|
const text = await item.textContent();
|
|
|
|
console.log(`\n========== ITEM ${i + 1} ==========`);
|
|
console.log('HTML:');
|
|
console.log(html);
|
|
console.log('\nText Content:');
|
|
console.log(text);
|
|
console.log('='.repeat(40));
|
|
}
|
|
|
|
} catch (error: any) {
|
|
console.error('Error:', error.message);
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
}
|
|
|
|
main().catch(console.error);
|