LoginSignup
8
10

More than 1 year has passed since last update.

puppeteerで言語を日本語に設定する方法

Last updated at Posted at 2019-02-15

スクレイピングをする時に、ブラウザを日本語対応で立ち上げたいとがあると思うのでその方法を解説します。

puppeteerで言語を日本語に設定する方法

次のようにすることで日本語にすることができます。

const puppeteer = require('puppeteer');
(async () => {
  const browser = puppeteer.launch({
    args: ['--lang=ja'] // デフォルトでは言語設定が英語なので日本語に変更
  });
  const page = await browser.newPage();
  await page.setExtraHTTPHeaders({
    'Accept-Language': 'ja-JP'
  });
})()

以上です。

終わりに

私は現在、Web3のサービスの開発をしています。詳しくはこちらの記事をご覧下さい。
無料でイーサリアムが当たる、Web3時代の寄付サイトを作った話

8
10
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
8
10