← back to Nationalrealestate

cap_search2.cjs

20 lines

const { chromium } = require('playwright');
(async () => {
  const url = process.argv[2] || 'https://corkwallcovering.com/';
  const q = process.argv[3] || 'blue';
  const out = process.argv[4] || '/tmp/search-proof.png';
  const b = await chromium.launch();
  const page = await b.newPage({ viewport: { width: 1280, height: 900 } });
  await page.goto(url, { waitUntil: 'networkidle', timeout: 30000 });
  const sel = '#grid .card, #grid a.card, [data-card]';
  const before = await page.$$eval(sel, els => els.length).catch(()=>0);
  await page.fill('#searchInput', q);           // type into the REAL in-page search
  await page.waitForTimeout(1300);              // debounce + re-render
  const after = await page.$$eval(sel, els => els.length).catch(()=>0);
  const stat = await page.$eval('#statLine', el=>el.textContent).catch(()=> '');
  console.log('url:', url, '| query:', q, '| cards before:', before, '| after:', after, '| statLine:', stat.trim());
  await page.screenshot({ path: out, fullPage: false });
  console.log('screenshot:', out);
  await b.close();
})().catch(e => { console.error('ERR', e.message); process.exit(1); });