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)

你可能感兴趣的:(Python,selenium,chrome,爬虫)