How to use https with Jython

Asked by Edmundo VN

Sometimes I need to access web pages and get its contents, with sikuli I can open the browser and do it, but I would like to know if it can be done using Python. I tried the module request, urllib, urllib2. And seems SSL support inside Jython is broken.

Im using Sikuli 1.1.0 with Linux.

Im having the same problem as this question: https://answers.launchpad.net/sikuli/+question/259267

To simplify the problem, a simple code like that doesn't work inside Sikuli, but works in a Python script outside Sikuli:

import urllib2
response = urllib2.urlopen('https://www.httpsnow.org/')
html = response.read()

The problem is that I need to deal with a webservice through https, so I cannot do that with the browser. I can do that simply executing curl in the shell :), so at the end I have an alternative.

But is this possible inside Sikuli, using any Python module being interpreted through Jython?

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
RaiMan (raimund-hocke) said :
#1

This is a Jython problem.

You should try to solve it with the Jython resources.
With 1.1.0 the bundled Jython version 2.7b3

You might use Sikuli to start an interactive pure Jython session on command line this way:

java -cp <path-to-your>sikulix.jar org.python.util.jython

import urllib2 seems to work

... but
urllib.urlopen('https://bugs.launchpad.net/sikuli')

... produces various Java exceptions, depending on the given URL.
Since I have no experience with SSL, I cannot interpret the results.

Can you help with this problem?

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

To post a message you must log in.