使用Visual Basic在Internet Explorer中选择Google搜索结果

时间:2012-05-30 13:29:30

标签: vb.net internet-explorer vba

我有用于Google的VB代码,填写搜索栏,然后点击搜索按钮。有没有办法让我的程序在搜索后选择一个特定的结果?即。我搜索“奶酪”,我希望我的程序选择倒数第二个结果(在这种情况下,它是wwww.chuckecheese.com)

2 个答案:

答案 0 :(得分:0)

我最终使用Sendkeys来模拟键盘上的标签键和向下箭头键。然后,您可以使用这两个键导航到所需的搜索结果

答案 1 :(得分:-1)

你可以使用google api

转到http://code.google.com/p/google-api-for-dotnet/

下载GoogleSearchAPI_0.4_alpha.zip

提取它并在项目中添加对dll文件的引用(在.net 2文件夹中)

你可以像这样使用它

首先导入库

Imports Google.API.Search

然后在子或函数中将代码设为

    Dim rf As String = "http://www.google.com"
    Dim v As New Google.API.Search.GwebSearchClient(rf)
    Dim result = v.Search(TextBox1.Text, 40)
    ' number (40) is the amount of fetched results ( change it if you want )
     For Each item In result

        If item.Url.Contains("chuckecheese") Then
            '  your code goes here
        End If



    Next