www.pudn.com > SearchEngine.zip > Form1.vb, change:2006-08-08,size:2383b


Imports Search_Engine.MSN 
Imports Search_Engine.Google 
Imports Yahoo.api 
Imports System.Net 
Public Class Form1 
 
    Private Sub btnGoogle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGoogle.Click 
        ' Create a Google Search object 
        Dim google As New GoogleSearchService 
        Try 
            ' Invoke the search method 
            Dim r As GoogleSearchResult = google.doGoogleSearch("Ggn0em1QFHIlqGA2SjnqBXfGMxySe6Ez", txtGoogle.Text, 0, 1, False, "", False, "", "", "") 
            ' Extract the estimated number of results for the search and display it 
            Dim estResults As Integer = r.estimatedTotalResultsCount 
            TextBox1.Text = CStr(estResults) 
            'Catch ex As System.Web.Services.Protocols.SoapException 
            '    MsgBox(ex.Message) 
            'End Try 
        Catch ex As WebException 
            MsgBox(ex.Message) 
        End Try 
    End Sub 
 
    Private Sub btnYahoo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnYahoo.Click 
        Dim yahoo As New YahooSearchService 
        Try 
            Dim resultSet As WebSearchResponse.ResultSet 
            resultSet = yahoo.WebSearch("YahooExample", txtYahoo.Text, "all", 10, 1, "any", True, True, "en") 
 
            TextBox1.Text = resultSet.totalResultsAvailable 
        Catch ex As WebException 
            MsgBox(ex.Message) 
        End Try 
    End Sub 
 
    Private Sub btnMSN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMSN.Click 
        ' Create a Google Search object 
        Dim msn As New MSNSearchService() 
        Dim searchRequest As New SearchRequest() 
        Dim searchResponse As SearchResponse 
        searchRequest.AppID = "D0D323E3B105DCD5CF92967B5F3A136E642EA7D5" 
        searchRequest.Query = txtMSN.Text 
        searchRequest.CultureInfo = "en-sg" 
        'searchRequest.Requests =  
        Try 
            ' Invoke the search method 
            searchResponse = msn.Search(searchRequest) 
            ' Extract the estimated number of results for the search and display it 
            'Dim estResults As Integer = r.estimatedTotalResultsCount 
            'TextBox1.Text = searchResponse.Responses.Length 
        Catch ex As WebException 
            MsgBox(ex.Message) 
        End Try 
    End Sub 
End Class