目录
puppeteer 是一个基于nodejs 调用chrome进行网页截图的库,chrome并不需要UI界面,一般访问网页,模拟点击操作等,在自动化测试和网络爬虫中非常有用。
那么linux 下面如何安装chrome呢?一起来探索一下。
第一步,添加repo
源
使用vim工具新建google.repo文件
vi /etc/yum.repos.d/google.repo
然后按 i 进入编辑模式,拷贝以下代码,按ESC再输入:wq保存退出
[google]
name=Google-x86_64
baseurl=http://dl.google.com/linux/rpm/stable/x86_64
enabled=1
gpgcheck=0
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
第二步,安装chrome
更新yum源,安装chrome,注意这是安装比较新的版本,
yum update
yum install google-chrome-stable
# 卸载chrome软件指令
# yum remove google-chrome-stable
如果后面发现比如某些功能不好用,可以卸载原来的,自行下载软件包本地安装
yum localinstall google-chrome-stable-104.0.5112.101-1.x86_64.rpm
第三步,查看chrome版本,并确定chrome安装位置
查看chrome版本,看是否符合要求
google-chrome --version
#安装后程序文件路径一般在
# /opt/google/chrome???/chrome
第四步,安装驱动chromedriver
酌情看是否有必要去安装对应调用驱动了。