I am trying to read https url, getting ssl import error

Asked by Anand

Hi i am trying to import to read a https page so am using to import ssl , it gives me a import error is there any other way to do it ?

import urllib2,ssl
context = ssl._create_unverified_context()
response = urllib2.urlopen('https://', context=context)
html = response.read()
print(html)

That's the code am using getting error in the first line Import error no module named ssl , where as i tried to run the same code in a diff compiler it worked perfectly

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Edmundo VN (edmundo-vn) said :
#1

I don't know how to explain exactly the problem with context creation with the ssl module. But generally speaking, Jython is known to have problems with SSL implementation, you cannot use the HTTPS protocol and theres no workaround (in Jython). Some days ago Jython 2.7.1 RC was to be releasead and is supposed to address some issues with the SSL implementation, it seems it was delayed to fix some Java 9 problems. When released, it worth a try to see if something started to work. You can get more information directly from Jython mailing lists to check exactly what is the problem with SSL in Jython and what 2.7.1 RC will start to fix.

Revision history for this message
Anand (anandha-p) said :
#2

Thank you Edmundo

Can you help with this problem?

Provide an answer of your own, or ask Anand for more information if necessary.

To post a message you must log in.