Reputation: 27
I am making a program to do web searches. I have the code set up to search what ever you enter in an input box in 3 different search engines (Google, Bing and Yahoo) and then it will open the browser with the results pages. But what I want is for it to automatically go to the first site on the results page, then make itself visible. If this is possible, please leave the modified code to do it in Google. Here is what I have so far:
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
Upvotes: 0
Views: 2236
Reputation: 1042
I made some changes on your code. and it will work
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
Upvotes: 1