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

版权声明: https://blog.csdn.net/t1anyuan/article/details/79478110
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()

问题解决

猜你喜欢

转载自blog.csdn.net/t1anyuan/article/details/79478110
今日推荐