LoginSignup
0
1

More than 1 year has passed since last update.

playwrightでブラウジングの自動化

Last updated at Posted at 2021-09-15

前回puppeteerの記事を書いて、使っていたらplaywrightを見つけました。コマンドも同じで、こちらの方が複数ブラウザー対応など便利そうだったのでサクッと切り替えました。python用などもあるようです。

Dockerファイル

DockerFile
FROM mcr.microsoft.com/playwright:focal

WORKDIR /app

...ubuntuベースなので少し大きいですが、公式docker対応は楽ですね。日本語も問題ありませんでした。

サンプル

yahoo.js
const playwright = require('playwright')

;(async () => {
  const browser = await playwright.chromium.launch()
  const context = await browser.newContext()
  const page = await context.newPage()
  await page.goto('https://www.yahoo.co.jp/')
  await page.screenshot({ path: `yahoo.png` })
  await browser.close()
})()

参考

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1