selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH

来源:互联网 发布:有关网络防沉迷的ppt 编辑:程序博客网 时间:2024/05/24 02:01

笔者小白在使用selenium+phantomjs的时候,出现了这样的报错信息:

selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH

下面给出解决方法:

browser = webdriver.PhantomJS(executable_path=r'C:\Users\lyh\Anaconda2\phantomjs-2.1.1-windows\bin\phantomjs.exe')

就是说要下载,安装 phantomjs-2.1.1-windows
这是下载地址:http://phantomjs.org/download.html

然后文件解压就可以直接用,在代码中替换掉你自己的解压的文件路径就可以了。

注意这里使用的是windows系统,在路径前面需要加上r,参考给出的代码语句。

参考资料:
1、http://blog.csdn.net/crisschan/article/details/52849961 2017.8.3
2、http://blog.csdn.net/codechelle/article/details/65666091 2017.8.3
3、http://blog.csdn.net/bzd_111/article/details/50496500 2017.8.3

阅读全文
2 0
原创粉丝点击