const { chromium } = require('playwright-core'); const PAGES = [ ['portal','http://127.0.0.1/portal/',8000,false], ['wm_zh_default','http://127.0.0.1/wm/',30000,false], ]; (async () => { const b = await chromium.launch({ executablePath: '/data/tools/chrome-headless-shell-linux64/chrome-headless-shell', args: ['--no-sandbox','--disable-dev-shm-usage','--use-gl=swiftshader','--enable-unsafe-swiftshader'], }); for (const [name,url,wait] of PAGES) { const ctx = await b.newContext({ viewport:{width:1600,height:1000}, locale:'zh-CN' }); const page = await ctx.newPage(); await page.goto(url,{waitUntil:'domcontentloaded',timeout:60000}); await page.waitForTimeout(wait); await page.screenshot({path:`/data/shots/${name}.png`}); const t=(await page.evaluate(()=>document.body.innerText)).replace(/\s+/g,' '); console.log(name, 'zh_chars', (t.match(/[一-龥]/g)||[]).length, '|', t.slice(0,150)); await ctx.close(); } await b.close(); })();