找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 2573|回复: 0

[求助] python2.7 NameError: name 'PROTOCOL_SSLv3' is not define

1

主题

1

帖子

1

积分

贫民

积分
1
完美世界 发表于 2018-5-5 21:46:58 | 显示全部楼层 |阅读模式
from gevent import monkey
import gevent
import urllib2

monkey.patch_all()

def run_task(url):
    print 'Visit --> %s' % url
    try:
        response = urllib2.urlopen(url)
        data = response.read()
        print '%d bytes recevied from %s.' % (len(data),url)
    except Exception,e:
        print e

if __name__ == '__main__':
    urls = ['https://github.com/','https://www.python.org','http://www.cnblogs.com/']
    greenlets = [gevent.spawn(run_task,url) for url in urls]
    gevent.joinall(greenlets)

运行时报错:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/gevent/monkey.py", line 192, in patch_all
  File "build/bdist.linux-x86_64/egg/gevent/monkey.py", line 121, in patch_socket
  File "build/bdist.linux-x86_64/egg/gevent/socket.py", line 731, in <module>

  File "build/bdist.linux-x86_64/egg/gevent/ssl.py", line 392, in <module>
    if not isinstance(purpose, _ASN1Object):
NameError: name 'PROTOCOL_SSLv3' is not defined

gevent安装的是gevent-0.13.1。
python菜鸟,请各位大神指教。代码是《Python爬虫开发与项目实战》中的协程一节实例

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表