你的 arm 和 x64 还有问题呢(深度踩坑),应该 arm64 上的 pyppeteer 调用 chrome(开源的那个有问题),我之前写的是 pyppeteer 调用 firefox
Dockerfile
```
FROM node:16
# examples: https://github.com/puppeteer/puppeteer/blob/main/docker/Dockerfile
RUN apt-get update \
&& apt-get install -y wget gnupg firefox-esr fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-khmeros fonts-kacst fonts-freefont-ttf libxss1
ENV PUPPETEER_PRODUCT=firefox
WORKDIR /home/app
COPY ./package.json /home/app
COPY ./firefox.js /home/app
RUN npm install
RUN mkdir screenshots
CMD echo “Hello World”
```
调用
```
const puppeteer = require('puppeteer-core');
(async() => {
const browser = await puppeteer.launch({
product: 'firefox',
headless: true,
executablePath: "/usr/bin/firefox",
defaultViewport: { width: 1700, height: 800 },
args: [
]
});
const page = await browser.newPage();
await page.goto('https://www.baidu.com/');
console.log('saving baidu screenshot');
await page.screenshot({ path: 'screenshots/baidu.png', fullPage: true });
await browser.close();
})();
```
环境需要你自己搭建下 |