Pythonでは、これを行うことができます:
import webbrowser
webbrowser.open_new("http://example.com/")
渡されたURLをデフォルトのブラウザで開きます
Ruby同等のものはありますか?
まず、 Launchy gemをインストールします。
$ gem install launchy
次に、これを実行できます:
require 'launchy'
Launchy.open("http://stackoverflow.com")
これはほとんどのプラットフォームで機能するはずです。
link = "Insert desired link location here"
if RbConfig::CONFIG['Host_os'] =~ /mswin|mingw|cygwin/
system "start #{link}"
elsif RbConfig::CONFIG['Host_os'] =~ /darwin/
system "open #{link}"
elsif RbConfig::CONFIG['Host_os'] =~ /linux|bsd/
system "xdg-open #{link}"
end
Macのみのソリューション:
system("open", "http://stackoverflow.com/")
または
`open http://stackoverflow.com/`
最もシンプルなWinソリューション:
`http://www.example.comを開始`
Linuxのみのソリューション
system("xdg-open", "http://stackoverflow.com/")
これも機能します:
system("start #{link}")
Windowsのみのソリューション:
require 'win32ole'
Shell = WIN32OLE.new('Shell.Application')
Shell.ShellExecute(...)
WindowsでIEの場合は、次のようにしてください。 http://rubyonwindows.blogspot.com/search/label/watir Selenium Rubyも確認してください: http://Selenium.rubyforge。 org/getting-started.html
HTH