If i pass full web address like: https://gaana.com it opens through my default browser chrome. But when i pass, ganna.com , the web page is perfectly open through microsoft edge. Any help about why the browser changes?
import webbrowser
alink = input('Enter the name: ')
new = 2
webbrowser.open(alink, new=new)
There is no error in general, but browser changes from default(chrome) to microsoft edge browser
That's most likely because your system doesn't know how to open the URL properly when no protocol was specified. Why don't you just prepend the protocol when the user has not passed any?
Example:
import webbrowser
alink = input('Enter the name: ')
new = 2
# protocol always comes before "://"
temp = alink.split('://')
if len(temp) > 2: # no protocol was specified
# let's use HTTP then
alink = "http://" + alink
webbrowser.open(alink, new=new)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With