Puppeteerで日本語文字化けを防ぐRTA


たぶんこれが一番早いと思います

FROM buildkite/puppeteer:5.2.1

ENV LANG ja_JP.UTF-8

RUN apt-get update && \
    apt-get -y install locales fonts-ipafont fonts-ipaexfont && \
    echo "ja_JP UTF-8" > /etc/locale.gen && locale-gen
$ docker build . -t puppeteer_ja

実行

qiita.js
const puppeteer = require('puppeteer');

(async () => {
    const url = 'https://qiita.com/';

    const browser = await puppeteer.launch({
        args: [
            '--no-sandbox',
            '--disable-setuid-sandbox'
        ]
    });
    const page = await browser.newPage();
    await page.goto(url);
    await page.screenshot({ path: 'image.jpg' })
    await browser.close();
})();
$ node qiita.js
  • image.jpg