Ask Your Question
0

Macro python without ssl?

asked 2015-12-10 03:50:06 +0200

pysb gravatar image

updated 2015-12-11 04:17:40 +0200

Alex Kemp gravatar image

Reference: LibreOffice Versão: 5.0.3.2

Hello guys!

I´m trying to make a python macro with urllib module to access a https:// website, but it seems SSL was not implemented.

I also tried with requests, and had the same problem. If I use a http:// page, it works, but the same can´t be said when it´s a https:// page.

Here´s my pseucode:

----------[some Codeformatting by karolus]

import uno
from com.sun.star.awt.PosSize import POSSIZE
import urllib.request
import urllib.parse
from urllib.request import urlopen
import os
from os.path import isdir,expanduser
import pickle
import sys
import http.cookiejar
import ssl
import sys
def access_webpage():
    with urllib.request.urlopen('https://www.google.com.br') as f:
        print(f.read(300))

g_exportedScripts = access_webpage()

the error:

com.sun.star.uno.RuntimeExceptionError during invoking function consulta_CPF in module file:///C:/Program%20Files%20(x86)/LibreOffice%205/share/Scripts/python/CPF.py (<class 'urllib.error.URLError'>: <urlopen error unknown url type: https>
C:\Program Files (x86)\LibreOffice 5\program\python-core-3.3.3\lib\urllib\request.py:1316 in function unknown_open() [raise URLError('unknown url type: %s' % type)]
C:\Program Files (x86)\LibreOffice 5\program\python-core-3.3.3\lib\urllib\request.py:447 in function _call_chain() [result = func(*args)]
C:\Program Files (x86)\LibreOffice 5\program\python-core-3.3.3\lib\urllib\request.py:492 in function _open() ['unknown_open', req)]
C:\Program Files (x86)\LibreOffice 5\program\python-core-3.3.3\lib\urllib\request.py:469 in function open() [response = self._open(req, data)]
C:\Program Files (x86)\LibreOffice 5\program\python-core-3.3.3\lib\urllib\request.py:156 in function urlopen() [return opener.open(url, data, timeout)]
C:\Program Files (x86)\LibreOffice 5\share\Scripts\python\CPF.py:99 in function consulta_CPF() [with urllib.request.urlopen('https://www.google.com.br') as f:]
C:\Program Files (x86)\LibreOffice 5\program\pythonscript.py:869 in function invoke() [ret = self.func( *args )]
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2015-12-10 18:11:38 +0200

karolus gravatar image

Hallo

Your Code works for me without Errors (LO from Debian|Ubuntu repositories linked to System-python 3.4 on Linux-Mint17)
Anyway reduced to the necessary code in context:

from urllib.request import urlopen

def access_webpage():
    with urlopen('https://www.google.com.br') as f:
        print(f.read(300))
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-12-10 03:50:06 +0200

Seen: 432 times

Last updated: Dec 10 '15