spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / xml / column55

Google SVG Search I

C/C++ Developer (NYC)
Next Step Systems
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Eclipse Helios Update Brings New PHP Tools
Internet Explorer 9 Ups Standards Support
JBoss Portal 5 Release Easier to Use


More search parameters

The following parameters handle scrolling through the result set, the character encoding of documents, and several search options:

ParameterValueDescription
start0The offset into the result set
maxResults10The number of elements to be returned
filterfalseshow similar results
restrict''Restriction by country or topic
safeSearchfalseshow all results
lr''Language restriction
ie'latin1'Input character encoding
oe'latin1'Output character encoding

Parsing the results

The result variable is created on the fly according to the response type for the doGoogleSearch call. In this case it is a top-level hashtable containing an array resultElements, which in turn holds a hashtable with information for each search result, such as summary, title, and URL. It also contains a further hashtable with directory information from the Open Directory if present. We can easily print the structure with the following code:

foreach my $element (@{$result->{'resultElements'}}) {
  foreach my $key (keys(%$element)) {
    print $key, ': ', $element->{$key}, "\n";
  }
}

This produces a printout looking like this:

summary: Articles, columns, tools and resources.
title: <b>exploring</b> <b>XML - The Webmaster's Reference on <b>XML</b>:
  Free Tutorials <b>...</b>
hostName:
URL: http://www.webreference.com/xml/
directoryCategory: DirectoryCategory=HASH(0x863cca8)
cachedSize: 42k
relatedInformationPresent: 1
directoryTitle: Webreference.com: Xploring <b>XML</b>
snippet: Hack into the jungle of this hot new markup language with Exploring XML, a bi-weekly 
  column featuring tutorials, examples and training in XML, XSL style <b>...</b>
...

Conclusion

In less than ten lines of code we managed to query Google's search engine and print out the results. In the next installment we will pick out the most relevant bits and turn them into a graphical representation using SVG. Hope you will be with me then again, bye for now!


Produced by Michael Claßen

webref The latest from WebReference.com Browse >
Flashmaps' DynamicLocator: Interactive Maps for Small Areas · Flashmaps' AreaSelector: Interactive Maps for Wide Areas · The DB Mapper: Interactive Street-level Maps of U.S. and Canada
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags

URL: http://www.webreference.com/xml/column55/2.html
Created: Apr 29, 2002
Revised: Apr 29, 2002