James Batchelor
James Batchelor

Reputation: 129

Python: Get pywebview Current URL

I am using the pywebview library to open a page that will redirect the user to another url. What I would like to do is get the URL the user is directed to.

my code so far:

import urllib.request
import urllib.parse
import webview
import threading
import time

def openwebview():
    time.sleep(1)
    page = webview.create_window("URL_that_redirects_user")

def geturl():
    #what goes here?

t = threading.Thread(target = openwebview)
t.start()

I am using Windows, thanks!

Upvotes: 1

Views: 1981

Answers (2)

zvi
zvi

Reputation: 4706

Now you can do it:

def geturl():
    print(webview.get_current_url())

See here: https://github.com/r0x0r/pywebview/blob/master/examples/get_current_url.py

Upvotes: 0

r0x0r
r0x0r

Reputation: 428

Author of pywebview here. There is no way to get the current URL. Uou have to dig into an underlying webview to get the URL. Thanks for the suggestion, I will look into introducing this feature.

Upvotes: 2

Related Questions