首页 > 其他 > 详细

selenium 在centos中的配置

时间:2019-06-03 13:19:11      阅读:115      评论:0      收藏:0      [点我收藏+]
基本环境: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)

selenium 在centos中的配置

原文:https://blog.51cto.com/13990437/2404087

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!