Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to open a website in google chrome using webbrowser module

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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 🙂

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading