Google API - sporadic success
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > IIS server support > IIS ASP > Google API - sporadic success




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Google API - sporadic success  
botch@botchthecrab.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-16-06 10:52 PM

Hi! I'm trying to get some help implementing a classic ASP version of
the Google API search (http://www.google.com/apis/). I've got a version
that works, but it's very sporadic. Sometimes it works, sometimes it
comes back blank, sometimes it gives an error. No other ASP version of
this API has any problems.

Dim Google_Web_APIs_license_key, Search_String
Google_Web_APIs_license_key = "HIDDEN"
Search_String = Request("q")
If Search_String = "" Then
Search_String = "transformers"
End If
'
' The SOAP message (doGoogleSearch.xml) was downloaded from the Google
API soap-examples.
' Dump the SOAP message into an XML document and set the key value,
search string value and start index.
'
Set objInputXMLDoc = Server.CreateObject("Microsoft.XMLDOM")
objInputXMLDoc.load Server.MapPath("doGoogleSearch.xml")
objInputXMLDoc.selectSingleNode("//key").Text =
Google_Web_APIs_license_key
objInputXMLDoc.selectSingleNode("//q").Text = Search_String
objInputXMLDoc.selectSingleNode("//start").Text = 0
'
' Post the SOAP message.
'
Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objXMLHTTP.open "post", "http://api.google.com/search/beta2", False
objXMLHTTP.setRequestHeader "Content-Type", "text/xml"
objXMLHTTP.setRequestHeader "SOAPAction", "doGoogleSearch"
objXMLHTTP.send objInputXMLDoc
showXML(objXMLHTTP.responseText)
'
' Dump the results into an XML document.
'
Set objOutputXMLDoc = Server.CreateObject("Microsoft.XMLDOM")
objOutputXMLDoc.loadXML objXMLHTTP.responseText
'
' Parse the XML document.
'
Set Nodes = objOutputXMLDoc.selectNodes("//item")
For Each Node In Nodes
Response.Write "<a href=""" & Node.selectSingleNode("URL").Text & """>"
& Node.selectSingleNode("title").Text & "</a>
" & VbCrLf
'Response.Write Node.selectSingleNode("snippet").Text & "

" & VbCrLf
Next

Function showXML(XMLSource)
Response.Clear
Response.Write XMLSource
Response.End
End Function

The page is at http://www.botchthecrab.com/searchNew2.asp
By default it searches for "transformers", but you can change the
search parameter like so:
http://www.botchthecrab.com/searchNew2.asp?q=football

You have to reload a few times to get all the desired results, but I
guarantee it works sometimes and sometimes not.

Any help would be appreciated!

~ Botch






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 03:01 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register