博客
关于我
Python--安装与配置selenium
阅读量:505 次
发布时间:2019-03-07

本文共 643 字,大约阅读时间需要 2 分钟。

安装及使用的中文文档可以在这里找到

安装

# pip install selenium

配置

下载驱动

selenium3.x以上需要浏览器驱动,到这里下载相应驱动,

解压

解压驱动到/usr/bin/usr/local/bin

测试

运行下面代码,测试是否能正常使用

from selenium import webdriverfrom selenium.webdriver.common.keys import Keysdriver = webdriver.Firefox()driver.get('https://www.baidu.com')assert 'Python' in driver.titleelem = driver.find_element_by_name('q')elem.send_keys('pycon')elem.send_keys(Keys.RETURN)assert 'No results found.' not in driver.page_source# driver.close()

问题

No such file or directory: 'geckodriver'

没有装上驱动,或没有放到指定位置

Message: can not connect to the service geckodriver

可能是没有localhost,打开/etc/hosts,看里面有没有这样一句

127.0.0.1 localhost
没有就加上

转载地址:http://qopjz.baihongyu.com/

你可能感兴趣的文章
MongoDB出现Error parsing command line: unrecognised option ‘--fork‘ 的解决方法
查看>>
MongoDB学习笔记(8)--索引及优化索引
查看>>
ms sql server 2008 sp2更新异常
查看>>
MS UC 2013-0-Prepare Tool
查看>>
msbuild发布web应用程序
查看>>
MSCRM调用外部JS文件
查看>>
MSEdgeDriver (Chromium) 不适用于版本 >= 79.0.313 (Canary)
查看>>
msf
查看>>
MSSQL数据库查询优化(一)
查看>>
MSSQL日期格式转换函数(使用CONVERT)
查看>>
MSTP多生成树协议(第二课)
查看>>
MSTP是什么?有哪些专有名词?
查看>>
Mstsc 远程桌面链接 And 网络映射
查看>>
Myeclipse常用快捷键
查看>>
MyEclipse用(JDBC)连接SQL出现的问题~
查看>>
myeclipse的新建severlet不见解决方法
查看>>
MyEclipse设置当前行背景颜色、选中单词前景色、背景色
查看>>
MyEclipse配置SVN
查看>>
MTCNN 人脸检测
查看>>
MyEcplise中SpringBoot怎样定制启动banner?
查看>>