7
2

More than 3 years have passed since last update.

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

Last updated at Posted at 2020-09-05

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

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

image.jpg

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