Brian
Brian

Reputation: 13

Kivy UrlRequest with https

I'm trying to get Python 3.7 Kivy code to retrieve https web data using UrlRequest. Code works fine with http, but I get no data when I change the url to any https. When I compile and run with both http or https, both run without errors. Is there an import I need to add to make https work? This is test code. Thanks.

from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout

from kivy.network.urlrequest import UrlRequest
from functools import partial

class MainApp(App):
    def build(self):
        grid = GridLayout(cols=1)
        button1 = Button(text="Press to say Hello", 
        on_release=self.run_Hello)
        button2 = Button(text="Kivy UrlRequest", 
        on_release=self.run_UrlRequests)
        blank_button = Button(text="Click me!")
        grid.add_widget(button1)
        grid.add_widget(button2)
        grid.add_widget(blank_button)
        return grid

def run_Hello(self, *args):
    print("Hello")


def run_UrlRequests(self, *args):
    for i in range(10):
        self.r = UrlRequest("https://www.google.com", verify=False, 
    on_success=partial(self.update_label, i), 
    on_error=partial(self.error_label, i))

def update_label(self, i, *args):
    print(i)
    print("success")
    print(self.r.result)

def error_label(self, i, *args):
    print("failed")
    print(i)
    print(self.r.result)

MainApp().run()

Upvotes: 0

Views: 952

Answers (1)

Brian
Brian

Reputation: 13

def run_UrlRequests(self, *args):
    for i in range(10):
    self.r = UrlRequest("https://www.google.com", verify=False, 
    on_success=partial(self.update_label, i), on_error=partial(self.error_label, i)) 

I added verify=False after the UrlRequest, also to the original code. The code runs and generates a print statement of html data. Although this solves the https problem, I don't know if this apparent SSL issue has been addressed correctly.

Upvotes: 1

Related Questions