我要做的是从网站打开一个xml.zip文件,以获取Python项目的介绍。我很确定我的代码没有问题,但是当我去运行程序时,我得到了:
Traceback (most recent call last):
File "/Users/Chris/Documents/clientDownloadFile-Handout.py", line 16, in <module>
u = urllib2.urlopen("https://nvd.nist.gov/download/nvdcve-Recent.xml.zip")
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1240, in https_open
context=self._context)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1197, in do_open
raise URLError(err)
URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>
这是我的代码:
import urllib2
u=urllib2.urlopen("https://nvd.nist.gov/download/nvdcveRecent.xml.zip")
localFile = open('nvd.xml.zip', 'wb')
localFile.write(u.read())
localFile.close()
我做过一些研究,包括在这个网站上。我已经尝试过一些修改,如'import ssl'和其他'不安全'的解决方法来解决这个问题,但无济于事。我想知道是否有其他人(可能是Mac OS X El Capitan用户)遇到过此问题,以及是否有更安全的解决方法?
答案 0 :(得分:0)
网址已更改;请尝试https://nvd.nist.gov/feeds/xml/cve/nvdcve-2.0-Recent.xml.zip
。