Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
621 views
in Technique[技术] by (71.8m points)

search keywords in google through c# window application

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.com textbox2: "cricket"

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.

best regards

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...