GoogleSearchService |
SOAP Method : doGoogleSearch |
|
What is this?
- This is a web search using Google's web service
interface. The web service is defined by this WSDL
file.
- The search page shows how to use SQLData SOAP client library to
interact with the service.
- Search results are transformed into HTML segments using an XSLT
file.
Search Tips
- Use quotes to search word in sequence: "SOAP Client".
- Use related: to search related sites: i.e.,
related:soapclient.com.
- Use link: to get all links to a site: i.e.,
link:sqldata.com
Sample Code (SQLData
SOAP Client)
The following sample demonstrates how to do Google
searches using SQLData client library, note that the returned result
set is transformed using an XML style sheet (XSLT).
Dim MyAgent As SoapAgent
Set MyAgent = New SoapAgent
'Add message parameters, see http://google.com/apis for details
MyAgent.AddParameter "key", "your account key", ""
MyAgent.AddParameter "q", "string to search for", ""
MyAgent.AddParameter "start", "0", ""
MyAgent.AddParameter "maxResults", "10", ""
MyAgent.AddParameter "filter", "0", ""
MyAgent.AddParameter "restrict", "0", ""
MyAgent.AddParameter "safeSearch", "1", ""
MyAgent.AddParameter "lr", "lang_en", ""
MyAgent.AddParameter "ie", "", ""
MyAgent.AddParameter "oe", "", ""
'execute the method
MyAgent.ExecuteMethod "http://api.google.com/GoogleSearch.wsdl", "doGoogleSearch"
'Transform the result to HTML format using a style sheet.
MyResult = MyAgent.Transform("http://soapclient.com/xml/Google.xsl",
"","")
'Show the results ?
MsgBox MyResult
Sample ASP Code (SQLData
SOAP Client)
<%
set myAgent=Server.CreateObject("SQLDataSoap.SoapAgent")
start = Request("start")
if start = "" then
start = "0"
' add the parameter value, please use your own account key, see http://google.com/apis for details
MyAgent.AddParameter "key", "your_google_key", ""
MyAgent.AddParameter "q", Request("q"), ""
MyAgent.AddParameter "start", start, ""
MyAgent.AddParameter "maxResults", "10", ""
MyAgent.AddParameter "filter", "0", ""
MyAgent.AddParameter "restrict", "0", ""
MyAgent.AddParameter "safeSearch", "1", ""
MyAgent.AddParameter "lr", "1ang_en", ""
MyAgent.AddParameter "ie", "", ""
MyAgent.AddParameter "oe", "", ""
' Execute the method
MyAgent.ExecuteMethod "http://api.google.com/GoogleSearch.wsdl", "doGoogleSearch"
' transform the result using an XSLT style sheet.
Transformed = MyAgent.Transform("http://soapclient.com/xml/googleASP.xsl",
"","")
Response.Write(Transformed)
%>
Assume this is in the file
/google.asp, user can use:
http://yourhost/google.asp?q=KeywordToSearch
to trigger the service. The SOAP
Client Library contains a functioning ASP page in the GoogleSearch
directory.
Sample C/C++ Code (SQLData
SOAP Client)
Available at http://www.sqldata.com/soapclient/GoogleSearch.htm
|