专注于 JetBrains IDEA 全家桶,永久激活,教程
持续更新 PyCharm,IDEA,WebStorm,PhpStorm,DataGrip,RubyMine,CLion,AppCode 永久激活教程

CentOS下运行puppeteer问题

问题1:error while loading shared libraries: libXcomposite.so.1

81_1.png

找到下面这个链接 github.com/puppeteer/p…

发现少依赖

ldd chrome | grep not

81_2.png

解决方法:安装Chrome后,这些共享包就都安装了 安装Chrome

wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm 
yum install -y google-chrome-stable_current_x86_64.rpm
/opt/google/chrome/chrome --version

问题2:Running as root without –no-sandbox is not supported.

81_3.png

81_4.png

附测试代码 test.js

const puppeteer = require('puppeteer-core');

let platform = global.process.platform;
// platform MacOS:darwin Widnows:win32 CentOS:linux
let executablePath = '/opt/puppeteer/chrome-mac/Chromium.app/Contents/MacOS/Chromium';
if (platform == 'win32') {

} else if (platform == 'linux') {
    executablePath = '/opt/puppeteer/chrome-linux/chrome';
}

(async () => {
    console.log(executablePath);
    const brower = await puppeteer.launch({
        headless: false,
        executablePath: executablePath,
        args: ['--no-sandbox', '--disable-setuid-sandbox'],
        ignoreDefaultArgs: [
        '--enable-automation',
        ]
    });
    const page = await brower.newPage();
    await page.goto('http://www.baidu.com');

    await page.waitFor(5000);
    await brower.close();

})();

文章永久链接:https://tech.souyunku.com/43441

未经允许不得转载:搜云库技术团队 » CentOS下运行puppeteer问题

JetBrains 全家桶,激活、破解、教程

提供 JetBrains 全家桶激活码、注册码、破解补丁下载及详细激活教程,支持 IntelliJ IDEA、PyCharm、WebStorm 等工具的永久激活。无论是破解教程,还是最新激活码,均可免费获得,帮助开发者解决常见激活问题,确保轻松破解并快速使用 JetBrains 软件。获取免费的破解补丁和激活码,快速解决激活难题,全面覆盖 2024/2025 版本!

联系我们联系我们