selenium + PhantomJS使用时 PhantomJS报错解决

时间:2023-03-09 18:25:28
selenium + PhantomJS使用时 PhantomJS报错解决

selenium + PhantomJS使用时 PhantomJS报错解决

  • 在做动态网页爬虫时用到了selenium + PhantomJS,安装好之后运行时报错:
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 '

说是 Selenium 已经弃用 PhantomJS ,请使用火狐或者谷歌*面浏览器。
查找之后得到答案时selenium的版本问题,使用pip show selenium显示默认安装的是3.8.1版本

  • 卸载之后重新pip install selenium==2.48.0安装成功
    专门写出来这个版本号是因为我使用2.0.0安装报错
     error: package directory 'build\src\py\test' does not exist
    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in
    C:\Users\OLD_DR~1\AppData\Local\Temp\pip-build-vqjzohmy\selenium\

之后运行爬虫没有报错,搞定!!!