0

I searched the net but couldn't get anything that works. I am trying to write a python script which will trigger a timer if a particular url is opened in the current browser. How do i obtain the url from the browser.

2
  • Are you talking about selenium webdriver? Or just some browser that happens to be open at the same time as the script is running? The latter can be very difficult, it depends on the OS and the browser. Commented Feb 19, 2014 at 6:15
  • Just some browser that happens to be open at the same time. I only want it for Linux and Firefox, though a platform independent one would be an add on. Commented Feb 19, 2014 at 6:20

1 Answer 1

1
  1. You cannot do it platform independent way.
  2. You need to use pywin32 for Windows platform (or any other suitable module which provides access to platform API, for example pywm) to access window (you can get it by window name). After that you should analyse all child to get to window which represents URL string. Finally you can get text of this.
Sign up to request clarification or add additional context in comments.

1 Comment

A note on this - I'm not sure about Firefox on Linux, but sometimes applications do not register each of their components as separate OS "window" objects. In these cases it is not possible to retrieve the URL text with any reasonable amount of effort.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.