1

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.

10
  • what problem is it causing? Commented Sep 11, 2015 at 15:26
  • @PadraicCunningham My problem is that I don't want display Created new window in existing browser session. when I open a web site. Commented Sep 11, 2015 at 15:30
  • 1
    @PadraicCunningham I've just try it and it's not working. And now I understand how to do this, thanks :) . And, how can I close this question? Commented Sep 11, 2015 at 15:43
  • 1
    For ubuntu somethng like r = check_call(["sensible-browser",url],stdout=PIPE,stderr=PIPE) would work Commented Sep 11, 2015 at 15:48
  • 1
    @PadraicCunningham yes, that is. thanks :) Commented Sep 11, 2015 at 23:30

2 Answers 2

1

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 :)

Sign up to request clarification or add additional context in comments.

Comments

0

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

import os
url="www.google.com"

os.system("start "+url)

4 Comments

@KevinGuan, no it is windows, I would also generally use subprocess over os.system
@PadraicCunningham thanks. However subprocess.getoutput and subprocess.getstatusoutput are more useful :)
@KevinGuan, depends what you are doing and your version of python ;)
@PadraicCunningham Yeah :P , and I solve this problem now. Just like you said :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.