HLJ 发布于
2022-10-27 22:38:31
116阅读

playwright自动化截屏网页

下一篇文章:

nginx反向代理

const http = require('http');
http.createServer(function (req, res) {

  const { chromium, firefox, webkit } = require('playwright');
  (async () => {
    const browser = await chromium.launch();  // Or 'firefox' or 'webkit'.
    const page = await browser.newPage();
    await page.goto('http://www.good1230.com');
    await page.screenshot({ path: `screenshot.png` }); // 图片默认保存到同当前文件的目录下
    // other actions...
    await browser.close();
  })();

  res.writeHead(200, {'Content-Type': 'text/html'}); 
  res.write('Node.js says hello!');
  res.end();

}).listen(8080);
文章来源:https://playwright.dev/docs/api/class-playwright
最后生成于 2024-06-22 12:07:27
下一篇文章:

nginx反向代理

此内容有帮助 ?
0