9
votes

I'm opening a webpage in the default webbrowser on the system using python's webbrowser module.

I want to check if the site is already open in the browser and only open a new tab/window if it is not. Otherwise reload the already opened page.

Is there a way to do this with webbrowser module? If not, is there any other module i can use to do this.

3
that's not possible with the webbrowswer module. I'd doubt that it is possible at all. - SilentGhost
I agree with @SilentGhost. You would need a library which is able to interface with any possible browser the user has installed. Perhaps if you gave an idea of the higher-level problem you're trying to solve, we could offer some alternative solutions. - Michael Mior

3 Answers

3
votes

I don't think this is currently possible with the webbrowser module. There was a bug filed for this, but it was closed with status "Won't fix":

http://bugs.python.org/issue1753371

2
votes

use

webbrowser.open( url, new=0 ) 

this tries to open the website in the same windows if possible, if you set the new parameter to 1 a new window/tab will be generated

but i'm not sure if this works reliable on all plattforms

-3
votes

From http://docs.python.org/library/webbrowser.html#webbrowser.open_new_tab:

webbrowser.open_new_tab(url)

Open url in a new page (“tab”) of the default browser, if possible; otherwise equivalent to open_new().