1

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!

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Wow, wasn't expecting a response at this point, let alone from the author of pywebview! I figured out it was impossible but having it as a feature would be really helpful in future projects, thanks!
The get current url feature is implemented in pywebview 1.5.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.