Showing posts with label yahoo. Show all posts
Showing posts with label yahoo. Show all posts

Friday, May 18, 2007

Yahoo Search Script

Something to share...

Using MsXML.DOMDocument, you will be able to query Yahoo! API (
http://api.search.yahoo.com/WebSearchService/V1/webSearch?) .

Query Parameters used:


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Yahoo Search Script
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Const APP_ID = "insert your app ID"

'Grab the incoming search query or ask for one
If WScript.Arguments.Length = 0 Then
strQuery = InputBox("Enter a search Term")
Else
strQuery = WScript.Arguments(0)
End If

'Construct a Yahoo! Search Query
strLanguage = "en"
strReqURL = "http://api.search.yahoo.com/" & _
"WebSearchService/V1/webSearch?" & _
"appid=" & APP_ID & _
"&query=" & strQuery & _
"&language=" & strLanguage

'Start the XML Parser
Set MSXML = CreateObject("MSXML.DOMDocument")

'Set the XML Parser options
MSXML.Async = False

'Make the Request
strResponse = MSXML.Load(strReqURL)

'Make sure the request loaded
If (strResponse) Then

'Load the results
Set Results = MSXML.SelectNodes("//Result")

'Loop through the results
For x = 0 to Results.length - 1
strTitle = Results(x).SelectSingleNode("Title").text
strSummary = Results(x).SelectSingleNode("Summary").text
strURL = Results(x).SelectSingleNode("Url").text
strOut = (x + 1) & ". " & _
strTitle & vbCrLf & _
strSummary & vbCrLf & _
strURL & vbCrLf & vbCrLf
WScript.Echo strOut
Next

'Unload the results
Set Results = Nothing

End If

'Unload the XML Parser
Set MSXML = Nothing
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''