28
36

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

python から Web ブラウザを開く方法

Last updated at Posted at 2015-05-29

追記 (2015/05/30)

新しい投稿には,もう少しディープな内容が載っています.

動作環境:

  • Windows 7
  • Python 2.7.5

めちゃくちゃシンプル.

sample1.py
import webbrowser
url = "amazon.co.jp"
webbrowser.open(url)

ただし,これだとIEでWebサイトを開いてしまう.
自分の好みのブラウザ,たとえばchrome でWeb サイトを開きたいときは,

sample2.py
import webbrowser
url = "amazon.co.jp"
browser = webbrowser.get('"(chrome.exe までの絶対パス)" %s')
browser.open(url)

とする.

28
36
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
36

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?