I am running an HTTP server which serves a bitmap according to the dimensions in the browser URL i.e localhost://image_x120_y30.bmp
. My server is running in infinite loop and I want to get the URL any time user requests for BITMAP, and at the end I can extract the image dimensions from the URL.
The question asked here:
How to get current URL in python web page?
does not address my problem as I am running in infinite loop and I want to keep on getting the current URL so I can deliver the requested BITMAP to the user.
To get the current URL of a web page when using Selenium in Python, you can use the Selenium webdriver current_url attribute. The Selenium Python module gives you the tools you need to be able to automate many tasks when working with web browsers.
Answer: Use the window. location. href Property location. href property to get the entire URL of the current page which includes host name, query string, fragment identifier, etc.
We can obtain the URL of the current page with Selenium webdriver. This is achieved with the help of getCurrentUrl() method.
You can get the current url by doing
path_info = request.META.get('PATH_INFO')
http_host = request.META.get('HTTP_HOST')
.
You can add these two to get complete url.
Basically request.META returns you a dictionary which contain a lot of information. You can try it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With