Home Page - www.tele-pro.co.uk - Ecommerce Integration


Search > Google Web API Code

Google API Website Search - Google API customization, Google Web API integrationGoogle Web API Search - Code

Our Google Website Search and Google Web API Tools use the Google Web API to retrieve Google's search results. The main code for our Google Search is below.

Google Web API - Technical

The code is ASP VBScript, and no components need to be installed. The function uses the inbuilt XML HTTP object to access the Google API SOAP interface.

The query is formatted with the XML template doGoogleSearch.xml, which needs to be placed in the same folder as the script.

The GoogleResults function returns an array consisting of the URL, title, characterisation and description of each result.

 Go Download the Google Website Search Code
 Go Download the XML template doGoogleSearch.xml
 Go View the customised Google Website Search

Google Account

You need to have a Google Account and a Google Web API license key to use the Google Web API in programs or code.

Google Web API Search - Code

Option Explicit

Dim myKey
myKey = "Enter your key here"
Dim apigooglecom
apigooglecom = "http://api.google.com/search/beta2"

FUNCTION GoogleResults(gQuery, gKey, startpage)
'function returns array - URL, Title, Snippet, Desc

If Trim(gQuery) = "" Then Exit Function
If Trim(gKey) = "" Then Exit Function

Dim Qry
Set Qry = Server.CreateObject("MSXML2.DOMDocument")
Qry.load Server.MapPath("doGoogleSearch.xml")
Qry.selectSingleNode("//key").Text = trim(gKey)
Qry.selectSingleNode("//q").Text = trim(gQuery)
Qry.selectSingleNode("//start").Text = ((startpage-1)*10)
Qry.selectSingleNode("//maxResults").Text = 10

' Post the SOAP message.
Dim soap
Set soap = Server.CreateObject("MSXML2.ServerXMLHTTP")
soap.open "post", apigooglecom, False
soap.setRequestHeader "Content-Type", "text/xml"
soap.setRequestHeader "SOAPAction", "doGoogleSearch"
soap.send Qry ' Dump the results into an XML document.
Dim Res
Set Res = Server.CreateObject("MSXML2.DOMDocument")
Res.loadXML (soap.responseText)

' Parse the XML document.
Dim rURL
Dim rTitle
Dim rSnippet
Dim rDesc
Dim rsize
Dim resArray
ReDim resArray(10,4)
Dim Nodes, Node, c
c=0
Set Nodes = Res.selectNodes("//item")
For Each Node In Nodes

'retrieve the values
rURL=""
on error resume next
rURL = Node.selectSingleNode("URL").Text
rTitle = Node.selectSingleNode("title").Text
rSnippet = Node.selectSingleNode("snippet").Text
rDesc = Node.selectSingleNode("summary").Text
rsize = Node.selectSingleNode("cachedSize").Text
on error goto 0

if Trim(res_URL)<>"" then
'its a result
resArray(c, 0) = rURL
resArray(c, 1) = rTitle
resArray(c, 2) = rDesc
resArray(c, 3) = rSnippet
resArray(c, 4) = rsize
c=c+1
End If
Next

'return array
GoogleResults = resArray
End FUNCTION

Google API Links

 Go Google Web APIs - Home
 Go Google Web API FAQ
 Go Create a Google Account
 Go Google Web APIs Reference
 

Google Web API Tools

More Google Web API Tools are listed on this page.

Google API Website Search - Google API customization, Google Web API integrationGoogle Website Position Search Tool

Our Google Website Position Search Tool uses the Google Web API to determine your position in Google's search results.

Site Map Generator

The Site Map Generator displays pages on a website from the Google database, and generates a visual representation of the folder structure of the website.

 Go Google Web API Services
 Go Site Optimisation Service - Top Google Rankings
 

See Also - Search, SEO

Website Search
 Go Google Optimisation
 Go Google Sitemaps
Search Engine Optimisation
 Go SEO Optimisation Tools and Links
Search Engines and Directories
Google Website Position Search
Site Map

SEO Searches

 Go Website: Google SEO
 Go Website: Optimization
 Go Google: Google SEO
 

Search Keywords

website search, web search, search site, search engine, search directory, search index, google, search google, google seo, altavista, yahoo, adwords, metacrawler, submit, search, engine, submission, website, site map, google sitemaps

SEO, Site Optimisation

search engine optimisation, se optimization, search engine o, seo, top search engine rankings, top ranking, number 1 ranking, number one site, google seo, search engine positioning, rankings optimisation, search engine promotion, submission, positioning, website promotion, website marketing, site exposure, visibility, top result, first page, top ten, top placement, google web api, google api, internet marketing, pay per click, ppc campaign, paid inclusion, linking, web analytics
 

Top | Home | ECommerce | Hosting | Site Map | Search | © 2003-6 | Contact