user250145
user250145

Reputation:

Python Webbrowser question

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.

Upvotes: 10

Views: 3948

Answers (3)

thdoan
thdoan

Reputation: 19067

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

Upvotes: 3

remosu
remosu

Reputation: 5109

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().

Upvotes: -3

Nikolaus Gradwohl
Nikolaus Gradwohl

Reputation: 20124

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

Upvotes: 2

Related Questions