This is very simple client program that uses Google's web service. You
can download the SDK from Google.
The sample code is like the following.
private void buttonSearch_Click(object sender, System.EventArgs e)
{
labelSearchText.Text = "Searching...";
labelSearchText.Update();
GoogleSearchService s = new GoogleSearchService();
GoogleSearchResult r;
r = s.doGoogleSearch(
"", ; You license key!
textSearch.Text,
0,
10,
false, "", false, "", "", "");
string strFile = "result.html";
StreamWriter sw = File.CreateText(strFile);
sw.WriteLine("<HTML><HEAD></HEAD><BODY>");
foreach(DirectoryCategory dc in r.directoryCategories)
{
sw.Write("<b>Category</b> : ");
sw.WriteLine(dc.fullViewableName);
sw.WriteLine("<br><br><br>");
}
foreach(ResultElement re in r.resultElements)
{
string strTitle = "<a href=\"" + re.URL + "\">" +
re.title + "</a><br>";
sw.WriteLine(strTitle);
string strSnippet = re.snippet +"<br>";
sw.WriteLine(strSnippet);
string strLink = "<a href=\"" + re.URL + "\">" + re.URL + "</a> - "
+ re.cachedSize + "<br><br>";
sw.WriteLine(strLink);
sw.WriteLine("<br><br>");
}
sw.Close();
labelSearchText.Text = textSearch.Text + " 's web search";
int estResults = r.estimatedTotalResultsCount;
double ldTime = r.searchTime;
labelSearchResult.Text = "Total " + Convert.ToString(estResults) + " " +
"1 - 10 seach result Total time:" +
Convert.ToString(ldTime);
object obj = null;
DirectoryInfo di = new DirectoryInfo(Environment.CurrentDirectory);
string strFilePath = di.FullName + "\\" + strFile;
WebBrowser.Navigate(strFilePath, ref obj, ref obj, ref obj, ref obj);
}
// Google API homepage
//
private void linkLabel1_LinkClicked(object sender,
System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
object obj = null;
WebBrowser.Navigate("http:
ref obj, ref obj);
}