1 / 17

Google Web API

Google Web API. See: http://www.google.com/apis/. Concept:. With the Google Web APIs service, software developers can query more than 3 billion web documents directly from their own computer programs.

libba
Download Presentation

Google Web API

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Google Web API See: http://www.google.com/apis/

  2. Concept: • With the Google Web APIs service, software developers can query more than 3 billion web documents directly from their own computer programs. • Google uses the SOAP and WSDL standards so a developer can program in his or her favorite environment - such as Java, Perl, or Visual Studio .NET.

  3. Google Web APIs provide three service: • Search relative web pages according to the keyword(s) user supplies • Return the cached web page to the user by the URL user supplies • Correct the spell of the word user inputs

  4. Search Requests: • Search requests submit a query string and a set of parameters to the Google Web APIs service and receive in return a set of search results. Search results are derived from Google’s index of over 2 billion Web pages.

  5. Seach Request Format:

  6. Search Results Format: • Search Response----Each time you issue a search request to the Google service, a response is returned to you. (We will describe the meanings of the values returned to you.) • Result Element

  7. Search Response: <documentFiltering>--A Boolean value indicating whether filtering was performed on the search results <searchComments>--A text string intended for displaying to an end user <estimatedTotalResultsCount>--The estimated total number of results that exist for the query

  8. Continue: • <estimatIsExact>--A Boolean value indicating that the estimate value is actually the exact value • <resultElements>--An array of <resultElement> items. This corresponds to the actual list of search results • <searchQuery>--This is the value of <Q> for the search request

  9. Continue: • <startIndex>--Indicates the index (1-based) of the first search result in <resultElements> • <endIndex>--Indicates the index(1-based) of the last search result in <resultElements> • <searchTips>--A text string intended for displaying to the end user. It provides instructive suggestions on how to use Google

  10. Continue: • <directoryCategories>--An array of <directoryCategory> items • <searchTime>--Text, floating-point number indicating the total server time to return the search results, measured in seconds

  11. Cache Requests: • Cache requests submit a URL to the Google Web APIs service and receive in return the contents of the URL when Google’s crawlers last visited the page.

  12. Spelling Requests: • Spelling requests submit a query to the Google Web APIs service and receive in return a suggested spell correction for the query (if available).

  13. Java Implementation: • Google provides a java implementation of the Google Web APIs • We will take a look at it and provide an example finally.

  14. The java classes: • com.google.soap.search.GoogleSearch • com.google.soap.search.GoogleSearchResult • com.google.soap.search.GoogleSearchResultElement • com.google.soap.search.GoogleSearchFault • com.google.soap.search.GoogleSearchDirectoryCategory

  15. Usage Demo: • GoogleSearch s = new GoogleSearch(); • s.setKey(clientKey); • try { • if (directive.equalsIgnoreCase("search")) { • s.setQueryString(directiveArg); • GoogleSearchResult r = s.doSearch(); • System.out.println(r.toString()); • } else if (directive.equalsIgnoreCase("cached")) { • byte [] cachedBytes = s.doGetCachedPage(directiveArg); • String cachedString = new String(cachedBytes); • System.out.println(cachedString); • } else if (directive.equalsIgnoreCase("spell")) { • System.out.println("Spelling suggestion:"); • String suggestion = s.doSpellingSuggestion(directiveArg); • System.out.println(suggestion); • } • }

  16. Example program: • You can download the executive files and source files of the example from Dr. Wang’s home page.

More Related