需要使用VBS打开搜索引擎查询的网站

时间:2014-11-17 20:37:48

标签: browser vbscript

我正在制作一个进行网络搜索的程序。我将代码设置为搜索您在3个不同搜索引擎(Google,Bing和Yahoo)的输入框中输入的内容,然后它将打开带有结果页面的浏览器。但我想要的是它自动转到结果页面上的第一个站点,然后让自己可见。如果可以,请保留修改后的代码,以便在Google中执行此操作。以下是我到目前为止的情况:

sub Loading
do while brw.busy
wscript.sleep 350
loop
end sub
query=inputbox("Please Enter What You Would Like To Search:","Multi-Engine Internet Searcher")
'down-Google
set brw=CreateObject("InternetExplorer.Application")
brw.navigate "https://www.google.ca/#q=" & (query)
brw.toolbar=false
brw.statusbar=true
brw.height=650
brw.width=950
brw.left=0
brw.top=0
brw.resizable=true
Call Loading
brw.visible=true
'up-google
'down-bing
set brw=CreateObject("InternetExplorer.Application")
brw.navigate "http://www.bing.com/search?q=" & (query)
brw.toolbar=false
brw.statusbar=true
brw.height=650
brw.width=950
brw.left=0
brw.top=0
brw.resizable=true
Call Loading
brw.visible=true
'up-bing
'down-yahoo
set brw=CreateObject("InternetExplorer.Application")
brw.navigate "https://search.yahoo.com/search;_ylt=A0LEVyBsK2pU4OUAtrpXNyoA;_ylc=X1MDMjc2NjY3OQRfcgMyBGZyA3NmcARncHJpZANzcVJmTGtGSVJ5V2FZOWVJcW9NVl9BBG5fcnNsdAMwBG5fc3VnZwM5BG9yaWdpbgNzZWFyY2gueWFob28uY29tBHBvcwMwBHBxc3RyAwRwcXN0cmwDBHFzdHJsAzMEcXVlcnkDVFlVBHRfc3RtcAMxNDE2MjQ0MDA3?p=" & (query)
brw.toolbar=false
brw.statusbar=true
brw.height=650
brw.width=950
brw.left=0
brw.top=0
brw.resizable=true
Call Loading
brw.visible=true
'up-yahoo

1 个答案:

答案 0 :(得分:1)

我对您的代码进行了一些更改。它会起作用

query=inputbox("Please Enter What You Would Like To Search:","Multi-Engine Internet Searcher")

'quit if cancel
if query = "" then wscript.quit 1

google(query)
yahoo(query)
bing(query)

'---------wait---------
sub Loading(brw)
  do while brw.busy
    wscript.sleep 350
  loop
end sub
'---------wait---------

'---------SetAttributes---------
sub brwAtributes(brw)
  brw.toolbar=false
  brw.statusbar=true
  brw.height=450
  brw.width=650
  brw.left=0
  brw.top=0
  brw.resizable=true
end sub
'---------SetAttributes---------

'---------view on browser---------
sub visibleBrowser(brw)
  brwAtributes(brw)
  Call Loading(brw)
  Set results = brw.document.all.tags("h3")(0).all.tags("a")(0)
  brw.Navigate results
  Call Loading(brw)
  brw.visible=true
end sub

'---------Google---------
sub google(query)
  set brw=CreateObject("InternetExplorer.Application")
  brw.Navigate "http://www.google.com/search?q=" & (query)
  visibleBrowser(brw)
end sub

'---------bing---------
sub bing(query) 
  set brw=CreateObject("InternetExplorer.Application")
  brw.Navigate "http://www.bing.co.jp/search?q=" & (query)
  visibleBrowser(brw)
end sub

'---------yahoo---------
sub yahoo(query)
  set brw=CreateObject("InternetExplorer.Application")
  brw.navigate "https://search.yahoo.com/search;_ylt=A0LEVyBsK2pU4OUAtrpXNyoA;_ylc=X1MDMjc2NjY3OQRfcgMyBGZyA3NmcARncHJpZANzcVJmTGtGSVJ5V2FZOWVJcW9NVl9BBG5fcnNsdAMwBG5fc3VnZwM5BG9yaWdpbgNzZWFyY2gueWFob28uY29tBHBvcwMwBHBxc3RyAwRwcXN0cmwDBHFzdHJsAzMEcXVlcnkDVFlVBHRfc3RtcAMxNDE2MjQ0MDA3?p=" & (query)
  visibleBrowser(brw)
end sub