>>> from SOAPpy import WSDL
#create a WSDL.Proxy object and point it at your local copy of Google's WSDL file.
>>> server = WSDL.Proxy('./GoogleSearch.wsdl')
According to the WSDL file, Google offers three functions: doGoogleSearch,
doGetCachedPage, and doSpellingSuggestion. These do exactly what they sound
like: perform a Google search and return the results programmatically, get access to the cached
version of a page from the last time Google saw it, and offer spelling suggestions for commonly
misspelled search words.
>>> server.methods.keys()
[u'doGoogleSearch', u'doGetCachedPage', u'doSpellingSuggestion']
The doGoogleSearch function takes a number of parameters of various types. Note that
while the WSDL file can tell you what the arguments are called and what datatype they are, it
can't tell you what they mean or how to use them. It could theoretically tell you the acceptable
range of values for each parameter, if only specific values were allowed, but Google's WSDL
file is not that detailed. WSDL.Proxy can't work magic; it can only give you the information
provided in the WSDL file.
>>> callInfo = server.methods['doGoogleSearch']
>>> for arg in callInfo.inparams:
... print arg.name.ljust(15), arg.type
...
key (u'http://www.w3.org/2001/XMLSchema', u'string')
q (u'http://www.w3.org/2001/XMLSchema', u'string')
start (u'http://www.w3.org/2001/XMLSchema', u'int')
maxResults (u'http://www.w3.org/2001/XMLSchema', u'int')
filter (u'http://www.w3.org/2001/XMLSchema', u'boolean')
restrict (u'http://www.w3.org/2001/XMLSchema', u'string')
safeSearch (u'http://www.w3.org/2001/XMLSchema', u'boolean')
lr (u'http://www.w3.org/2001/XMLSchema', u'string')
ie (u'http://www.w3.org/2001/XMLSchema', u'string')
oe (u'http://www.w3.org/2001/XMLSchema', u'string')
Here is a brief synopsis of all the parameters to the doGoogleSearch function:
• key − Your Google API key, which you received when you signed up for Google web services.
• q − The search word or phrase you're looking for. The syntax is exactly the same as Google's web form, so if
you know any advanced search syntax or tricks, they all work here as well.
• start − The index of the result to start on. Like the interactive web version of Google, this function returns
10 results at a time. If you wanted to get the second "page" of results, you would set start to 10.
• maxResults − The number of results to return. Currently capped at 10, although you can specify fewer if
you are only interested in a few results and want to save a little bandwidth.
• filter − If True, Google will filter out duplicate pages from the results.
• restrict − Set this to country plus a country code to get results only from a particular country.
Example: countryUK to search pages in the United Kingdom. You can also specify linux, mac, or bsd to
search a Google−defined set of technical sites, or unclesam to search sites about the United States
government.
• safeSearch − If True, Google will filter out porn sites.
• lr ("language restrict") − Set this to a language code to get results only in a particular language.
• ie and oe ("input encoding" and "output encoding") − Deprecated, both must be utf−8.
Comments
Post a Comment
https://gengwg.blogspot.com/