Urllib HTTPS request: <urlopen error unknown url type: https>
I have a script in python3.4 and everything was fine until the website uploaded the file with permission to use https, and now I get an error message, but I can’t figure out how I can extract the file.
My script imports the following library and uses urlretrive to get the file earlier. Since it is now redirected to https with a 302 redirect. I get some error.
import urllib
import urllib.request
urllib.request.urlretrieve("http://wordpress.org/latest.tar.gz", "/thefile.gz")
My mistake: -
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/urllib/request.py", line 178, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "/usr/local/lib/python3.4/urllib/request.py", line 153, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.4/urllib/request.py", line 461, in open
response = meth(req, response)
File "/usr/local/lib/python3.4/urllib/request.py", line 571, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/local/lib/python3.4/urllib/request.py", line 493, in error
result = self._call_chain(*args)
File "/usr/local/lib/python3.4/urllib/request.py", line 433, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.4/urllib/request.py", line 676, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/usr/local/lib/python3.4/urllib/request.py", line 455, in open
response = self._open(req, data)
File "/usr/local/lib/python3.4/urllib/request.py", line 478, in _open
'unknown_open', req)
File "/usr/local/lib/python3.4/urllib/request.py", line 433, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.4/urllib/request.py", line 1257, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib.error.URLError: <urlopen error unknown url type: https>
+4
1 answer
Most likely your installation or Python operating system is broken.
Python HTTPS, HTTPS. .
HTTPS support is only available if the socket module was compiled with SSL support.
https://docs.python.org/3/library/http.client.html
, Python. Python python.org
+13