selenium 在centos中的配置

匿名 (未验证) 提交于 2019-12-02 23:37:01

基本环境:centos7,python3.x
1.安装selenium
pip3 install selenium

2.安装chrome-browser
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm --no-check-certificate
yum install ./google-chrome-stable_current_x86_64.rpm

3.下载chromedriver(注意要和chrome-browser版本对应)
wget http://chromedriver.storage.googleapis.com/2.43/chromedriver_linux64.zip
解压此文件,并将文件移动到/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)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!