Please refer to the following code:
from six.moves.urllib.request import FancyURLopener
class ParanoidURLopener(FancyURLopener):
def http_error_default(self, url, fp, errcode, errmsg, headers):
raise Exception('URL fetch failure on {}: {} -- {}'.format(url, errcode, errmsg))
ParanoidURLopener().retrieve("https://s3.amazonaws.com/img-datasets/mnist.pkl.gz", "a.pkl.gz")
I get the
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:645)
I searched around, and found this question on SO, but it is very old bug and seems fixed (code in that question works for me).
PS_1
: code is taken from Keras source code
PS_2
: this is more to the point version of this question
EDIT_1
These errors happen with this file only.
If I open a pdf
file, it works perfectly.
>>> ParanoidURLopener().retrieve("http://anh.cs.luc.edu/python/hands-on/3.1/Hands-onPythonTutorial.pdf", "a.pdf")
('a.pdf', <http.client.HTTPMessage object at 0x7f623da36128>)
and with this as well it works
>>> ParanoidURLopener().retrieve("http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz", "a.gz")
('a.gz', <http.client.HTTPMessage object at 0x7f623da36860>)