我在Ubuntu 16.10上。我正在尝试使用python的urlretrieve()
函数下载图像。我收到以下错误。
File "downloadImage.py", line 9, in <module>
downloadWebImage("https://qph.ec.quoracdn.net/main-qimg-601accaf841bba9145d3c46bece1ea10-p")
File "downloadImage.py", line 7, in downloadWebImage
urllib.urlretrieve(url, fullName)
File "/usr/lib/python2.7/urllib.py", line 98, in urlretrieve
return opener.retrieve(url, filename, reporthook, data)
File "/usr/lib/python2.7/urllib.py", line 245, in retrieve
fp = self.open(url, data)
File "/usr/lib/python2.7/urllib.py", line 213, in open
return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 443, in open_https
h.endheaders(data)
File "/usr/lib/python2.7/httplib.py", line 1053, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 897, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 859, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 1278, in connect
server_hostname=server_hostname)
File "/usr/lib/python2.7/ssl.py", line 353, in wrap_socket
_context=self)
File "/usr/lib/python2.7/ssl.py", line 601, in __init__
self.do_handshake()
File "/usr/lib/python2.7/ssl.py", line 830, in do_handshake
self._sslobj.do_handshake()
IOError: [Errno socket error] [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)
我的代码也是:
import random
import urllib
def downloadWebImage(url):
name = random.randrange(1,1000)
fullName = str(name) + '.jpg'
urllib.urlretrieve(url, fullName)
downloadWebImage("https://qph.ec.quoracdn.net/main-qimg-601accaf841bba9145d3c46bece1ea10-p")
那么错误是什么,它们为什么会发生?他们的修复是什么?