centos7安裝selenium

基本環境:centos7,python3.x

1.安裝selenium

pip3 install seleniumhtml

2.安裝chrome-browser

wget https://dl.google.com/linux/d... --no-check-certificate
yum install ./google-chrome-stable_current_x86_64.rpmpython

3.下載chromedriver(注意要和chrome-browser版本對應)

wget http://chromedriver.storage.g...
解壓此文件,並將文件移動到/usr/bin目錄下
unzip chromedriver_linx64.zip
mv chromedriver /usr/bin/linux

4.測試selenium是否可用,請執行如下python腳本,如返回html內容,則說明安裝成功

python3 test.pyweb

from selenium import webdriver
url='http://bing.com'
option = webdriver.ChromeOptions()
option.add_argument('--no-sandbox')
option.add_argument('--headless')
driver = webdriver.Chrome(chrome_options=option)
driver.get(url)
print(driver.page_source)chrome

相關文章
相關標籤/搜索