标签:UNC dimens element 脚本 puppeteer factor 执行 turn const
/在文档上下文里执行脚本,并返回结果
(async () => {
const browser = await puppeteer.launch({
args: [‘--no-sandbox‘],
timeout: 10000,
});
const page = await browser.newPage();
await page.goto(‘http://www.163.com‘);
// Get the "viewport" of the page, as reported by the page.
const dimensions = await page.evaluate(() => {
return {
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight,
deviceScaleFactor: window.devicePixelRatio
};
});
console.log(‘Dimensions:‘, dimensions);
await browser.close();
})();
标签:UNC dimens element 脚本 puppeteer factor 执行 turn const
原文地址:https://www.cnblogs.com/justart/p/9747476.html