linux下啟動selenium-爬蟲並安裝谷歌瀏覽器和驅動


一.升級yum

[root@selenium ~]# yum update -y
[root@selenium ~]# yum -y groupinstall "Development tools"
[root@selenium ~]# yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel psmisc libffi-devel

二.配置谷歌瀏覽器安裝

第一步

[root@selenium ~]# vim /etc/yum.repos.d/google-chrome.repo

第二步

#按i進入編輯模式粘貼內容
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
#:wq保存退出

第三步

[root@selenium ~]# yum -y install google-chrome-beta.x86_64 --nogpgcheck
#你也可以查看你的版本yum list | grep chrome
#安裝是否成功查詢
[root@selenium ~]# google-chrome --version

三.安裝驅動

驅動去官網下載:https://sites.google.com/a/chromium.org/chromedriver/downloads
上傳至於/usr/local/bin/文件目錄
給與權限即可

[root@selenium ~]#  chmod 777 /usr/local/bin/chromedriver

四.卸載驅動(需要卸載可操作此步驟)

# yum remove google-chrome

刪除舊驅動包文件

[root@selenium ~]# cd /usr/local/bin/
[root@selenium bin]# ls
chromedriver
[root@selenium bin]# rm -rf chromedriver

上傳新的驅動

[root@selenium bin]# rz chromedriver
chromedriver

安裝新的瀏覽器

[root@selenium bin]# yum -y install google-chrome-beta.x86_64 --nogpgcheck

給與權限

[root@selenium bin]# chmod 777 /usr/local/bin/chromedriver
從新安裝驅動完成


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM