← back to Eur Recrawl

probe-osbnet.mjs

30 lines

// probe-osbnet.mjs — capture osborneandlittle.com XHR/API + image hosts to find the feed.
import { chromium } from 'playwright';
import path from 'node:path';
const ctx = await chromium.launchPersistentContext(path.join(process.cwd(), '.auth', 'osbpub'), {
  headless: false, channel: 'chrome', viewport: { width: 1440, height: 900 },
});
const page = ctx.pages()[0] || await ctx.newPage();
const api = new Set(), imgs = new Set();
page.on('request', (r) => {
  const u = r.url();
  if (/api\.|\/api\/|\.json|graphql|algolia|search/i.test(u) && !/\.(js|css|woff|png|jpg|svg)/i.test(u)) api.add(r.method() + ' ' + u.slice(0, 130));
  if (/\.(jpg|jpeg|png|webp)/i.test(u) && !/logo|icon|sprite|flag/i.test(u)) imgs.add(u.split('?')[0]);
});

await page.goto('https://www.osborneandlittle.com/', { waitUntil: 'domcontentloaded', timeout: 60000 }).catch((e) => console.log('nav', e.message));
await page.waitForTimeout(3000);
for (const s of ['#onetrust-accept-btn-handler', 'button:has-text("Accept All")']) { const b = await page.$(s).catch(() => null); if (b) { await b.click().catch(() => {}); break; } }

// go to a wallpaper listing then a product
const wall = await page.$('a[href*="wallpaper" i], a:has-text("Wallpapers"), a:has-text("Wallpaper")').catch(() => null);
if (wall) { await wall.click().catch(() => {}); await page.waitForTimeout(4000); console.log('wallpaper listing @', page.url()); }
const prod = await page.$('a[href*="/product" i], a[href*="/wallpaper" i][href*="/"], .product a, [class*=product] a[href], [class*=tile] a[href]').catch(() => null);
if (prod) { const h = await prod.getAttribute('href').catch(() => null); if (h) { await page.goto(new URL(h, page.url()).href, { waitUntil: 'domcontentloaded', timeout: 45000 }).catch(() => {}); await page.waitForTimeout(4000); console.log('product @', page.url()); } }

console.log('\n=== API/XHR calls ==='); [...api].slice(0, 25).forEach((u) => console.log('  ' + u));
console.log('\n=== image hosts ==='); const hosts = new Set([...imgs].map((u) => { try { return new URL(u).host; } catch { return u; } })); [...hosts].forEach((h) => console.log('  ' + h));
console.log('\n=== sample product image URLs ==='); [...imgs].slice(0, 8).forEach((u) => console.log('  ' + u));
await page.waitForTimeout(1000);
await ctx.close();