0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

puppeteerのpage.evaluate内でのlogをサーバーに出力する

Posted at

問題

puppeteerのpage.evaluate内の結果などデバッグで見たいときにそのままconsole.logを記述すると操作しているChromeのconsoleにでるだけでGUIなしではみれない。
node.jsサーバーの出力で見たい。

解決

ブラウザを作成するときのオプションにdumpio:trueをつける
一例として以下

sample.js
const browser = await puppeteer.launch({
    headless: true,
    dumpio: true,
    args: ['--lang=ja']
})

こうすることでブラウザ上でのconsole出力もnode.jsの出力に転送してくれる。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?