centos7安装chrome和chromedriver以及selenium

How To Install Chrome On Centos 7
Download the google-chrome-stable

wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm

Lets install chrome now.

yum localinstall google-chrome-stable_current_x86_64.rpm

Lets check if chrome is installed.

google-chrome --version
90.0.4430.24

Lets download chromdriver
[https://npm.taobao.org/mirrors/chromedriver/]
(https://npm.taobao.org/mirrors/chromedriver/)
and find your chrome version

wget https://npm.taobao.org/mirrors/chromedriver/90.0.4430.24/chromedriver_linux64.zip

Lets install chromdriver

 unzip chromedriver_linux64.zip 
 mv chromedriver /usr/bin
 chmod +x /usr/bin/chromedriver

and start your chromedriver

/usr/bin/chromedriver
ChromeDriver was started successfully.

Lets install Selenium first using pip.

pip install selenium
Collecting selenium
  Using cached https://files.pythonhosted.org/packages/80/d6/4294f0b4bce4de0abf13e17190289f9d0613b0a44e5dd6a7f5ca98459853/selenium-3.141.0-py2.py3-none-any.whl
Requirement already satisfied: urllib3 in /home/anaconda3/lib/python3.7/site-packages (from selenium) (1.24.2)
Installing collected packages: selenium
Successfully installed selenium-3.141.0

Lets try using the Selenium now in Ipython. Import following packages in python and run with no head

from selenium import webdriver
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_argument("--headless")
chromeOptions.add_argument("--remote-debugging-port=9222")
chromeOptions.add_argument('--no-sandbox')
driver = webdriver.Chrome('/usr/bin/chromedriver',chrome_options=chromeOptions)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值