Calling Chrome browser from webbrowser.get () in Python

How can I call the webbrowser.get () function to open a Chrome browser? I am running Ubuntu 11.04 and Python version 2.7. Using webbrowser.get ('chrome') gives an error.

+7
source share
2 answers

A quick workaround is to make Chrome the default browser on your system, and then just use webbrowser.get (). I just checked this on ubuntu 10.10 and it worked fine.

EDIT

Just looked through the code / usr / lib / python 2.6 / webbrowser.py. You should do the following:

In [5]: webbrowser.get('/usr/bin/google-chrome %s').open('http://google.com') Created new window in existing browser session. Out[5]: True In [6]: webbrowser.get('firefox %s').open('http://google.com') Out[6]: True 

those. the '% s' parameter in the get () parameter is a key function.

+9
source

for mac do it
webbrowser.get("open -a /Applications/Google\ Chrome.app %s").open("http://google.com")

+1
source

All Articles