Remi Guan
Remi Guan

Reputation: 22282

How to use webbrowser module open a web site but at background in python 3?

I'm looking for a function that can open a web site use my default web browser. So I find the webbrowser module. It's working but not so good, like this:

>>> import webbrowser 
>>> webbrowser.open('https://www.google.com/')
True
>>> Created new window in existing browser session.

However I'm using chrome, and when I'm using chrome open a web site in the terminal, it'll display Created new window in existing browser session. if I have opened chrome.

But now I don't want these text, I've tried tmp = webbrowser.open('https://www.google.com/'), but it's not working.

Upvotes: 1

Views: 1674

Answers (2)

Remi Guan
Remi Guan

Reputation: 22282

just like @PadraicCunningham said, I need this

>>> r = subprocess.getoutput("google-chrome-stable https://www.google.com/")
>>> r
Created new window in existing browser session.'
>>> 

Very easy, I don't need use the webbrowser module. Thanks everyone :)

Upvotes: 1

Bhawesh Chandola
Bhawesh Chandola

Reputation: 511

what i got from your question this should help you out:

import os
url="www.google.com"

os.system("start "+url)

Upvotes: 0

Related Questions