centos7安装selenium

42次阅读

共计 627 个字符,预计需要花费 2 分钟才能阅读完成。

基本环境:centos7,python3.x

1. 安装 selenium

pip3 install selenium

2. 安装 chrome-browser

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

3. 下载 chromedriver(注意要和 chrome-browser 版本对应)

wget http://chromedriver.storage.g…
解压此文件,并将文件移动到 /usr/bin 目录下
unzip chromedriver_linx64.zip
mv chromedriver /usr/bin/

4. 测试 selenium 是否可用,请执行以下 python 脚本,如返回 html 内容,则说明安装成功

python3 test.py

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)

正文完
 0