c.l.u.s.GoogleSearchService : class documentation

Part of canonical.launchpad.utilities.searchservice View In Hierarchy

Implements interfaces: canonical.launchpad.interfaces.searchservice.ISearchService

See ISearchService.

A search service that search Google for launchpad.net pages.

Method client_id The client-id issued by Google.
Method site The URL to the Google Search Engine service.
Method search See ISearchService.
Method create_search_url Return a Google search url.
Method _checkParameter Check that a parameter value is not None or an empty string.
Method _getElementsByAttributeValue Return a list of elements whose named attribute matches the value.
Method _getElementByAttributeValue Return the first element whose named attribute matches the value.
Method _parse_google_search_protocol Return a PageMatches object.
@property
def client_id(self):
The client-id issued by Google.

Google requires that each client of the Google Search Engine service to pass its id as a parameter in the request URL.

@property
def site(self):
The URL to the Google Search Engine service.

The URL is probably http://www.google.com/search.

def search(self, terms, start=0):
See ISearchService.

The config.google.client_id is used as Google client-id in the search request. Search returns 20 or fewer results for each query. For terms that match more than 20 results, the start param can be used over multiple queries to get successive sets of results.

ReturnsISearchResults (PageMatches).
RaisesGoogleWrongGSPVersion if the xml cannot be parsed.
def _checkParameter(self, name, value, is_int=False):
Check that a parameter value is not None or an empty string.
def create_search_url(self, terms, start=0):
Return a Google search url.
def _getElementsByAttributeValue(self, doc, path, name, value):
Return a list of elements whose named attribute matches the value.

The cElementTree implementation does not support attribute selection (@) or conditional expressions (./PARAM[@name = 'start']).

ParametersdocAn ElementTree of an XML document.
pathA string path to match the first element.
nameThe attribute name to check.
valueThe string value of the named attribute.
def _getElementByAttributeValue(self, doc, path, name, value):
Return the first element whose named attribute matches the value.
ParametersdocAn ElementTree of an XML document.
pathA string path to match an element.
nameThe attribute name to check.
valueThe string value of the named attribute.
def _parse_google_search_protocol(self, gsp_xml):
Return a PageMatches object.
Parametersgsp_xmlA string that should be Google Search Protocol version 3.2 XML. There is no guarantee that other GSP versions can be parsed.
ReturnsISearchResults (PageMatches).
RaisesGoogleResponseError if the xml is incomplete.
GoogleWrongGSPVersion if the xml cannot be parsed.
API Documentation for Launchpad, generated by pydoctor at 2010-09-27 00:00:11.