I am trying to open a website from python in google chrome, but when I run this code –
import webbrowser
webbrowser.open('youtube.com')
It opens Youtube in edge browser. Then I tried to change the default browser, but it still didn’t work, so I ran this code:
import webbrowser
webbrowser.get('C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s').open('youtube.com')
But this code didn’t give any output. So how can I open a website in google chrome using python.
>Solution :
Try this:
import webbrowser
url = "https://www.youtube.com/"
webbrowser.open(url)
I use https://www.youtube.com/ instead of youtube.com and it will works 🙂