pyppeteer部署在centos上面的一系列问题


pyppeteer在win上都好说,不赘述。centos上就有些问题。

首先由于pyppeteer默认的下载地址需要FQ,所以程序自带的下载程序时下载不了,需要手动去以下地址下载。

'linux': 'https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/575458/chrome-linux.zip'
'mac': 'https://storage.googleapis.com/chromium-browser-snapshots/Mac/575458/chrome-mac.zip'
'win32': 'https://storage.googleapis.com/chromium-browser-snapshots/Win/575458/chrome-win32.zip'
'win64': 'https://storage.googleapis.com/chromium-browser-snapshots/Win_x64/575458/chrome-win32.zip'

完了以后将zip文件解压到 /root/.local/share/pyppeteer/local-chromium/575458 ,那串数字时版本号,会有变动的

其次可能得安装以下一系列依赖。

sudo yum install libXcomposite libXcursor libXi libXtst libXScrnSaver libXrandr atk at-spi2-atk gtk3 -y
另外需注意,如果使用root用户调用pyppeteer,则需要在 launch 中增加参数:–no-sandbox 才能正常运行。也就是像下面这样

await launch({'executablePath': exepath, 'headless': True,'args':['--no-sandbox']})

截图中文显示乱码,这是因为服务器上没有中文字体的包,解决方法参考下面链接:
https://www.cnblogs.com/huangyanqi/p/10609587.html

遇到pyppeteer.errors.NetworkError
将websockeet从7.0降到6.0能解决绝大部分这种问题

附链接:
判断自己是否是chrome headless 的网址 https://arh.antoinevastel.com/bots/areyouheadless


Author: Lic
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source Lic !
  TOC