pytthon + Selenium+chrome linux 部署

1,centos7 安装 google-chrome

(1) 添加chrome的repo源

 vi /etc/yum.repos.d/google.repo

[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

2 安装

yum -y install google-chrome-stable –nogpgcheck

3 查看版本号

google-chrome -version

chromedriver 下载地址 

http://npm.taobao.org/mirrors/chromedriver/

unzip 后  chmod 777 chromedriver


python 代码

chrome_opt = webdriver.ChromeOptions()
chrome_opt.add_argument('--headless')
chrome_opt.add_argument('--no-sandbox') #不加启动报错
chrome_opt.add_argument('--disable-gpu')

driver = webdriver.Chrome(chrome_options=chrome_opt, executable_path='/pythonSpider/chrome/chromedriver')

https://blog.csdn.net/zhiguoliu11/article/details/79563611

https://blog.csdn.net/u013849486/article/details/79466359

https://www.jianshu.com/p/6f1c86e65b8a

猜你喜欢

转载自www.cnblogs.com/angdh/p/10117255.html
今日推荐