Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Change url of web browser using webbrowser-control

Ok, I know that if you want to open a particular url using pyton you would run:

import webbrowser
webbrowser.open("buinvent.com")

But what if you want to change it to a different url in the web browser without opening a new window or a new tab in the web browser. Is there a way to do that?

like image 633
BUInvent Avatar asked Nov 27 '25 17:11

BUInvent


1 Answers

import webbrowser
webbrowser.open('google.com', new = 0)

And the docs says:

If new is 0, the url is opened in the same browser window if possible. If new is 1, a new browser window is opened if possible. If new is 2, a new browser page (“tab”) is opened if possible

https://docs.python.org/3/library/webbrowser.html

like image 81
mehulmpt Avatar answered Nov 30 '25 05:11

mehulmpt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!