topical media & game development
mashup-amazon-13-13-04-SimpleGoogle-Default.aspx.cs / cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using com.google.api;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void cmdGo_Click(object sender, EventArgs e)
{
// Create a Google Search object
GoogleSearchService myService = new GoogleSearchService();
// Invoke the search method
GoogleSearchResult myResults ;
myResults = myService.doGoogleSearch(
"[YOUR ID HERE]",
this.txtKeywords.Text,
0, 10,
true,
"",
true,
"",
"",
"");
// Prep the results area
lblResults.Text = "<ol>";
// Loop through each result and display it
foreach (ResultElement myResult in myResults.resultElements)
{
lblResults.Text += "<li><a href=\"" +myResult.URL + "\">" ;
lblResults.Text += myResult.title ;
lblResults.Text += "</a><br/>";
lblResults.Text += myResult.snippet + "<br/><br/></li>";
}
lblResults.Text += "</ol>";
}
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.