Introduction to Google API… - PowerPoint PPT Presentation

introduction to google api n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Introduction to Google API… PowerPoint Presentation
Download Presentation
Introduction to Google API…

play fullscreen
1 / 13
Introduction to Google API…
101 Views
Download Presentation
yuval
Download Presentation

Introduction to Google API…

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Introduction to Google API… By Pratheepan Raveendranathan NLP Group Meeting 10/10/2003

  2. What is Google API? • The Google Web APIs service allows software developers to query more than 3 billion web documents directly from their own computer programs. • Google uses the SOAP and WSDL standards to act as an interface between the user’s program and Google API. • Programming environments such as Java, Perl, Visual Studio .NET are compatible with Google API. Definitions from http:// www.google.com/apis/

  3. SOAP and WSDL SOAP: Simple Object Access Protocol WSDL: Web Services Description Language

  4. Google API for Perl SOAP:Lite Lite for Perl is a collection of Perl modules which provides a simple and lightweight interface to the SOAP both on client and server side. Sample Program: use SOAP::Lite; my $key='000000000000000000000000'; my $query="foo"; my $googleSearch = SOAP::Lite -> service("file:GoogleSearch.wsdl"); my $result = $googleSearch -> doGoogleSearch($key, $query, 0, 10,"false", "", $ print "About $result->{'estimatedTotalResultsCount'} results.\n";

  5. Google API for Java Google APi for Java is similar to Google API for Perl. Uses the SOAP module to interact with Google API

  6. Google API & Java package com.google.soap.search; import com.google.soap.search.GoogleSearch; import com.google.soap.search.GoogleSearchFault; import java.io.*; public class GoogleAPIDemo { public static void main(String[] args) { // Parse the command line if (args.length != 3) { printUsageAndExit(); } String clientKey = args[0]; String directiveArg = args[2]; // Report the arguments received System.out.println("Parameters:"); System.out.println("Client key = " + clientKey); System.out.println("Directive = " + directive); System.out.println("Args = " + directiveArg); // Create a Google Search object, set our authorization key GoogleSearch s = new GoogleSearch(); s.setKey(clientKey);

  7. // Depending on user input, do search or cache query, then print out result try { if (directive.equalsIgnoreCase("search")) { s.setQueryString(directiveArg); GoogleSearchResult r = s.doSearch(); System.out.println("Google Search Results:"); System.out.println("======================"); System.out.println(r.toString()); } else if (directive.equalsIgnoreCase("cached")) { System.out.println("Cached page:"); System.out.println("============"); byte [] cachedBytes = s.doGetCachedPage(directiveArg); // Note - this conversion to String should be done with reference // to the encoding of the cached page, but we don't do that here. String cachedString = new String(cachedBytes); System.out.println(new String(pageText)); System.out.println(cachedString); } else if (directive.equalsIgnoreCase("spell")) { System.out.println("Spelling suggestion:"); String suggestion = s.doSpellingSuggestion(directiveArg); System.out.println(suggestion); }

  8. Results [ URL = "http://www.ci.duluth.mn.us/" Title = "City of <b>Duluth</b> Official Webpage" Snippet = "Business in <b>Duluth</b>, It&#39;s summer in<b>Duluth</b>. <b>... <b> Check our Parks &amp; Recreation<br> pages for summer events. Visit <b>Duluth</b>, Comprehensive Plan. <b>...</b> " Directory Category = {SE="", FVN=""} Directory Title = "" Summary = "" Cached Size = "22k" Related information present = true Host Name = "" ],

  9. Spell Suggestion Query: java -cp googleapi.jar com.google.soap.search.GoogleAPIDemo iROSyfxQFHKjtA1CLcVQ3aGawqQW2j2Q spell Dulut Result: Parameters: Client key = iROSyfxQFHKjtA1CLcVQ3aGawqQW2j2Q Directive = spell Args = Dulut Spelling suggestion: Duluth

  10. Cached Query java -cp googleapi.jar com.google.soap.search.GoogleAPIDemo iROSyfxQFHKjtA1CLcVQ3aGawqQW2j2Q cached www.d.umn.edu/~tpederse Result: <h2> Registry of Latin American Researchers in NLP and CL </h2> <A HREF="http://www.d.umn.edu/~tpederse/registry/registry.cgi"> Visit the Registry! </a> <h2> My Site of the Month </h2> <a href="http://teach-computers.org"> <img src="http://teach-computers.org/images/omwe_link1.gif" alt="Open Mind word game" width="200" height="65" border="1"> </a>

  11. Some Ideas… • Duluth AND Vacation VS Hawaii and Vacation • NEAR Operator in Alta Vista • Positive & Negative inference beauty NEAR excellent beauty NEAR bad

  12. Problems • Limit of 1000 queries a day. • Google Web APIs service is a beta web program: meaning Google does not guarantee the availability of the service • One account per user.

  13. Conclusion…