我尝试使用 Groovy 连接到网页,
我尝试过这个,当 URL 为www.google.fr
String.metaClass.browse {
def handler = [(~/^Mac OS.*/) : { "open $it".execute() }, (~/^Windows.*/) : { "cmd /C start $it".execute() },
(~/.*/) : {
//--- assume Unix or Linux
def browsers = [ 'firefox'.'chrome' ]
//--- find a browser we know the location of
def browser = browsers.find {
"which $it".execute().waitFor() == 0
}
//--- and run it if one found
if( browser )
"$browser $it".execute()
}
]
def k = handler.find { k, …Run Code Online (Sandbox Code Playgroud) groovy ×1