Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current URL from browser using python

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.

like image 289
Chaudhry Waqas Avatar asked May 27 '15 10:05

Chaudhry Waqas


People also ask

How do I get the current URL in Python?

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.

How do I get the current URL?

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.

Which Webdriver method will get the current URL of the browser?

We can obtain the URL of the current page with Selenium webdriver. This is achieved with the help of getCurrentUrl() method.


1 Answers

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.

like image 164
Tasneem Haider Avatar answered Sep 20 '22 01:09

Tasneem Haider