small lecturenumber - hepage : Using Google's Web Servicessmall lecturenumber - hepage : SOAP reviewsmall lecturenumber - hepage : Interfacessmall lecturenumber - hepage : The Google WSDLsmall lecturenumber - hepage : Using the Google API with Pythonsmall lecturenumber - hepage : Inputssmall lecturenumber - hepage : Outputssmall lecturenumber - hepage : Result Elementssmall lecturenumber - hepage : Using the Google Web Service with Javasmall lecturenumber - hepage : SummaryDistributed Software DevelopmentUsing Google with SOAPChris BrooksDepartment of Computer ScienceUniversity of San FranciscoDepartment of Computer Science — University of San Francisco – p. 1/??9-2: Using Google’s Web Services•Google also provides a Web Services interface to their data.•They use SOAP, rather than REST.◦It’s possible to send a URL from a program, but results arereturned in HTML, rather than XML.•This was a big point of contention when Google put this out -they’d previously had a REST-style interface, which is no longerfreely available.Department of Computer Science — University of San Francisco – p. 2/??9-3: SOAP review•Recall that SOAP uses a procedural model, rather than adata-retrieval model.•Method/procedure names, input and output paramters areencoded in in the body of a SOAP message.•Service API is exposed as a WSSDL file◦A particular flavor of XML Schema.•This allows clients to automatically generate code to interfacewith the service.Department of Computer Science — University of San Francisco – p. 3/??9-4: Interfaces•The Google API toolkit has examples of using their service withJava and C#.•Dive Into Python shows how to use it with Python.•Ruby/Google seems to work, but I haven’t used it.Department of Computer Science — University of San Francisco – p. 4/??9-5: The Google WSDL•There are three client-side procedures that can be used:◦doGoogleSearch◦doSpellingSuggestion◦doGetCachedPage•doGoogleSearch is probably the most commonly-used one.Department of Computer Science — University of San Francisco – p. 5/??9-6: Using the Google API with Python•Here’s a simple example, adapted from Dive Into Python#!/usr/bin/pythonfrom SOAPpy import WSDLmykey = 12345 # get your own keysearch = WSDL.Proxy(’path/to/google.wsdl’)results = search.doGoogleSearch(key, buffy, 0, 10, False, "", False,"", "utf-8", "utf-8")for result in results.resultElements :print result.title, result.URL, result.snippetDepartment of Computer Science — University of San Francisco – p. 6/??9-7: Inputs•doGoogleSearch takes nine arguments:◦Your API key◦Your search string◦The starting result number◦The ending result number◦filter - remove duplicates?◦restrict- you can set this to country+ to get results fromparticular countries, e.g. ’countryUK’◦safeSearch◦lr - choose result language◦ie, oe - encoding of input/output - should be ’utf-8’Department of Computer Science — University of San Francisco – p. 7/??9-8: Outputs•This returns a dictionary-like object◦searchTips◦endIndex◦searchQuery◦resultElements◦estimatedTotalResultsCount◦searchTimeDepartment of Computer Science — University of San Francisco – p. 8/??9-9: Result Elements•ResuktElements is a list of results•Each result has:◦cachedSize◦title◦URL◦snippet◦summary◦directoryCategoryDepartment of Computer Science — University of San Francisco – p. 9/??9-10: Using the Google Web Service with Java•The calls and results look very similar - take a look at thejavadoc for examples.•(Ruby folks - the calls are very similar. Ruby/Google is notincredibly well-documented, but you should be used to that bynow :-)Department of Computer Science — University of San Francisco – p. 10/??9-11: Summary•Much of the complexity of SOAP can be (usually) hidden bytools that automatically generate proxy code from a WSDL.•This gives the user a programmatic interface like the one they’dget for working with any other library.•Google’s API is pretty simple and straightforward to use.Department of Computer Science — University of San Francisco – p.
View Full Document