const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch({ headless: false });
  const context = await browser.newContext();
  const page = await context.newPage();
  
  console.log('访问页面...');
  await page.goto('https://my.rfchost.com/index.php?rp=/store/jp2-tier-1-international-optimization-network');
  
  console.log('等待15秒...');
  await page.waitForTimeout(15000);
  
  const title = await page.title();
  console.log('标题:', title);
  
  const products = await page.evaluate(() => {
    const results = [];
    document.querySelectorAll('a[href*="pid="]').forEach(a => {
      const url = new URL(a.href);
      const pid = url.searchParams.get('pid');
      const card = a.closest('.product, .card, div');
      const name = card?.querySelector('h3, h4')?.textContent.trim();
      if (pid) results.push({ name: name || 'Unknown', pid });
    });
    return results;
  });
  
  console.log(JSON.stringify(products, null, 2));
  await browser.close();
})();
