I have used yahoo api for web search, we could get the totalResults available of resultset field as return value of WebSearch method.
I have used yahoo api for web search, we could get the totalResults available of resultset field as return value of WebSearch method.
I observed the results are different compared to manual search, they are much much lesss, like if the manual result shows 64 results,
webserach shows only 2.
following is the code snippet I used in VB.net
basedomain = Replace(url, "http://", "", 1)
basedomain = Mid(basedomain, 1, InStr(basedomain, "/") - 1)
url = "links:" & url & "-site:" & basedomain ' Url is used for search any keyword term
Dim yahoo As New YahooSearchService
Dim yahooresult As Yahoo.API.WebSearchResponse.ResultSet
yahooresult =
yahoo.WebSearch("EP4vW1bV34Fh4RZ94Z.RPOwOKG4Roi5hNTXJAWY89t4EjQzUeVgTy27FkuPrzTeo0DZlPjlx", url, "all",
10, 1, "any", True, True, "en")
MsgBox(yahooresult.totalResultsAvailable)
nyahooresult = yahooresult.totalResultsAvailable
The following function is used for websearch
Public Function WebSearch(ByVal appId As String, ByVal query As String, ByVal type As String, ByVal results As Short, ByVal
start As Integer, ByVal format As String, ByVal adultOk As Boolean, ByVal similarOk As Boolean, ByVal language As String) As
Yahoo.API.WebSearchResponse.ResultSet
Dim requestUri As String = String.Format(_searchYahooApiAddress +
"WebSearchService/V1/webSearch?appid={0}&query={1}&type={2}&results={3}&start={4}&format={5}&adult_ok={6}&simil
ar_ok={7}&language={8}", appId, HttpUtility.UrlEncode(query, Encoding.UTF8), type, results, start, format, IIf(adultOk, "1", "0"),
IIf(similarOk, "1", "0"), language)
Dim request As HttpWebRequest = CType(WebRequest.Create(requestUri), HttpWebRequest)
Dim ResultSet As Yahoo.API.WebSearchResponse.ResultSet = Nothing
Dim response As HttpWebResponse = Nothing
Dim responseStream As Stream = Nothing
Try
response = CType(request.GetResponse(), HttpWebResponse)
responseStream = response.GetResponseStream()
Dim serializer As New XmlSerializer(GetType(Yahoo.API.WebSearchResponse.ResultSet))
ResultSet = CType(serializer.Deserialize(responseStream), Yahoo.API.WebSearchResponse.ResultSet)
Finally
If Not (responseStream Is Nothing) Then responseStream.Close()
If Not (response Is Nothing) Then response.Close()
End Try
Return ResultSet
End Function
I tried checking thr' forums & sites for such problem but seems this is strange or new problem, did not get anyone having such
problem.
Thanks and Regards
Intellisoft team
www.Intellisoft.co.in
by
0 Replies