(Python 3.4.2) Can anyone help me get https pages from urllib? I spent hours trying to figure it out.
Here is what I'm trying to do (pretty simple):
import urllib.request
url = "".join((baseurl, other_string, midurl, query))
response = urllib.request.urlopen(url)
html = response.read()
Here my error is displayed at startup:
File "./script.py", line 124, in <module>
response = urllib.request.urlopen(url)
File "/usr/lib/python3.4/urllib/request.py", line 153, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.4/urllib/request.py", line 455, in open
response = self._open(req, data)
File "/usr/lib/python3.4/urllib/request.py", line 478, in _open
'unknown_open', req)
File "/usr/lib/python3.4/urllib/request.py", line 433, in _call_chain
result = func(*args)
File "/usr/lib/python3.4/urllib/request.py", line 1244, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib.error.URLError: <urlopen error unknown url type: 'https>
I also tried using data = None to no help:
response = urllib.request.urlopen(url, data=None)
I also tried this:
import urllib.request, ssl
https_sslv3_handler = urllib.request.HTTPSHandler(context=ssl.SSLContext(ssl.PROTOCOL_SSLv3))
opener = urllib.request.build_opener(https_sslv3_handler)
urllib.request.install_opener(opener)
resp = opener.open(url)
html = resp.read().decode('utf-8')
print(html)
A similar error occurs with this ^ script, where the error is found on the line "resp = ..." and complains that "https" is an unknown type of URL.
Python was compiled with SSL support on my computer (Arch Linux). I tried reinstalling python3 and openssl several times, but this does not help. I am not trying to completely remove python and then reinstall, because I will also need to remove many other programs on my computer.
Does anyone know what is going on?
----- EDIT -----
, . url ":" , , urllib . "% 3A", . !!!