Open12
【調査】Apple SiliconeのDevContainer内でHeadless chrome+Puppeteerを扱う
DebianベースのDevContainer内でHeadless Chrome + Puppeteer動いた
devcontainer.json
{
"name": "Debian",
"runArgs": [
"--platform=linux/amd64"
],
"image": "mcr.microsoft.com/vscode/devcontainers/base:0-bullseye",
"features": {}
}
必要な依存関係
sudo apt-get update
sudo apt-get install -y ca-certificates fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils
Node.js環境構築(簡易)
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.bashrc
nvm install --lts # (20あたりが入る)
npm i -g yarn
index.js
const puppeteer = require('puppeteer');
(async () => {
// Launch the browser and open a new blank page
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
// Navigate the page to a URL
await page.goto('https://developer.chrome.com/');
console.log(await page.title())
await browser.close();
})();
package.json
{
"name": "debian",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"puppeteer": "^22.2.0"
},
"scripts": {
"start": "node index.js"
}
}
Armで実装できるか調査