通过C#窗口应用程序在Google中搜索关键字 [英] search keywords in google through c# window application

查看:52
本文介绍了通过C#窗口应用程序在Google中搜索关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个刮板程序,该程序将在google中搜索关键字.我在启动我的刮板程序时遇到问题.我的问题是:假设窗口应用程序(c#)有2个文本框和一个按钮控件.第一个文本框包含"www.google.com",第二个文本框包含按键,例如:

i want to work on a scraper program which will search keyword in google. i have problem in starting my scraper program. my problem is: let suppose window application(c#) have 2 textboxes and a button control. first textbox have "www.google.com" and the 2nd textbox contain keywork for example:

textbox1:www.google.comtextbox2:板球"

textbox1: www.google.com textbox2: "cricket"

我希望代码添加到将在Google中搜索板球的按钮单击事件中.如果有人在C#中有编程想法,那么请帮助我.

i want code to add to the button click event that will search cricket in google. if anyone have a programing idea in c# then plz help me.

最诚挚的问候

推荐答案

我用Google搜索了我的问题并找到了解决上述问题的方法...我们可以为此目的使用google API ...当我们添加对google api的引用时,我们将在程序中添加以下名称空间......

i have googled my problem and found solution to the above problem... we can use google API for this purpose...when we add reference to google api then we will add the following namespace in our program...........

using Google.API.Search;

在按钮单击事件中编写以下代码

write the following code in button click event

 var client = new GwebSearchClient("http://www.google.com");
        var results = client.Search("google api for .NET", 100);
        foreach (var webResult in results)
        {
            //Console.WriteLine("{0}, {1}, {2}", webResult.Title, webResult.Url, webResult.Content);
            listBox1.Items.Add(webResult.ToString ());
        }

测试我的解决方案并发表评论.........谢谢大家

test my solution and give comments .........thanx everybody

这篇关于通过C#窗口应用程序在Google中搜索关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆