← back to Beverlyhillsvideos App
store/capture.mjs
19 lines
import { chromium } from '/Users/macstudio3/.npm-global/lib/node_modules/playwright/index.js';
const shots = [
{url:'https://beverlyhillsvideos.com/', file:'home.png', wait:2000},
{url:'https://beverlyhillsvideos.com/videos.html', file:'videos.png', wait:3500},
{url:'https://beverlyhillsvideos.com/map.html', file:'map.png', wait:4000},
{url:'https://beverlyhillsvideos.com/restaurants/spago.html', file:'spago.png', wait:2500},
{url:'https://beverlyhillsvideos.com/restaurants.html', file:'list.png', wait:2000},
];
const b = await chromium.launch();
const ctx = await b.newContext({ viewport:{width:440,height:956}, deviceScaleFactor:3, isMobile:true, hasTouch:true });
const page = await ctx.newPage();
for (const s of shots) {
try { await page.goto(s.url, {waitUntil:'networkidle', timeout:30000}); } catch { await page.goto(s.url, {waitUntil:'domcontentloaded'}); }
await page.waitForTimeout(s.wait);
await page.screenshot({ path:'store/caps/'+s.file });
console.log('captured', s.file);
}
await b.close();