怎么下载旧版本的Selenium

帅比萌擦擦* 提交于 2020-01-16 04:50:12

试运行一个爬虫:

from bs4 import BeautifulSoup
from selenium import webdriver
import urllib
driver = webdriver.PhantomJS(
executable_path='/usr/local/bin/phantomjs') # 浏览器的地址 如果是windows,应该是某个exe地址
def search(keyword):
url_keyword = urllib.parse.quote(keyword)
url = "http://www.tianyancha.com/search/" + url_keyword + "?checkFrom=searchBox"
print(url)
driver.get(url)
bsObj = BeautifulSoup(driver.page_source, "html5lib")
print(bsObj)
company_list = bsObj.find_all("span", attrs={"ng-bind-html": "node.name | trustHtml"})
for company in company_list:
print(company.get_text())
if name == 'main':
search("阿里巴巴 马云")

结果第二行就告诉我:
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
在命令行运行:

pip install selenium==2.33

参考链接:
https://www.jianshu.com/p/df5f141de455

https://pypi.python.org/pypi/selenium/2.42.1

http://www.yuqiaochuang.com/article/?article_id=33&category=Python教程

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!