helloworld / deploy /scripts /shot_zh.js
eduzrh's picture
Upload deploy/scripts/shot_zh.js with huggingface_hub
02121ea verified
Raw History Blame Contribute Delete
986 Bytes
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();
})();