开发者

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.


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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜