File size: 986 Bytes
02121ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const { chromium } = require('playwright-core');
(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] of [['wm_zh','http://127.0.0.1/wm/?lang=zh']]) {
    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(35000);
    await page.screenshot({ path: `/data/shots/${name}.png` });
    const t = (await page.evaluate(() => document.body.innerText)).replace(/\s+/g,' ');
    const zh = (t.match(/[一-龥]/g) || []).length;
    console.log(name, 'len', t.length, 'chinese_chars', zh);
    console.log('HEAD:', t.slice(0, 260));
    await ctx.close();
  }
  await b.close();
})();