自动摘要
正在生成中……
google-chrome-stable 安装(centos7系统):
curl https://intoli.com/install-google-chrome.sh | bash
安装后运行 google-chrome-stable --version
输出版本信息:Google Chrome 83.0.4103.116
使用以下命令进行截图:
google-chrome-stable --no-sandbox --headless --disable-gpu --screenshot https://www.baidu.com
图片保存为当前目录的 screenshot.png
。如果出现中文方块字,需要安装字体:
yum install -y wqy-microhei-fonts wqy-zenhei-fonts
安装chromedriver
去 https://npm.taobao.org/mirrors/chromedriver/ 找一个版本,我选择的是 83.0.4103.14
,选择对应的平台的zip文件,下载回来,解压后放到特定目录,运行 chromedriver
,输出对应的版本信息。
Starting ChromeDriver 83.0.4103.14 (be04594a2b8411758b860104bc0a1033417178be-refs/branch-heads/4103@{#119}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
[1592983335.107][SEVERE]: bind() failed: 无法指定被请求的地址 (99)
ChromeDriver was started successfully.
参考资料:
Centos安装Headless Chrome
Go进阶34:Chromedp浏览器模拟和截图微服务
golang使用chromedp实现网页截图