您的位置:首页 > Web前端 > JavaScript

UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chr

2018-03-07 22:38 776 查看
In [1]: from selenium import webdriver

In [2]: driver = webdriver.PhantomJS()
G:\Anaconda3\lib\sitepackages\selenium\webdriver\phantomjs\webdriver.py:49: UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead
warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless '

In [3]: quit()


报错的意思大概是

Selenium 已经弃用 PhantomJS ,请使用火狐或者谷歌无界面浏览器

查看selenium版本

C:\Users\zty>pip show selenium
Name: selenium
Version: 3.10.0
Summary: Python bindings for Selenium
Home-page: https://github.com/SeleniumHQ/selenium/ Author: UNKNOWN
Author-email: UNKNOWN
License: Apache 2.0
Location: g:\anaconda3\lib\site-packages
Requires:


原来目前默认安装的selenium版本为3.x

百度查得 安装2.x版本可解决此问题

so:

C:\Users\zty>pip uninstall selenium
C:\Users\zty>pip install selenium==2.48.0
Collecting selenium==2.48.0
Downloading selenium-2.48.0.tar.gz (805kB)
100% |████████████████████████████████| 808kB 5.1kB/s
Building wheels for collected packages: selenium
Running setup.py bdist_wheel for selenium ... done
Stored in directory: C:\Users\zty\AppData\Local\pip\Cache\wheels\5a\80\e9\7317945f05740b625382070b69cbccb2f37a00af0d95d4e428
Successfully built selenium
Installing collected packages: selenium
Successfully installed selenium-2.48.0

C:\Users\zty>ipython
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from selenium import webdriver

In [2]: driver = webdriver.PhantomJS()


问题解决
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐