Google SVG Search I (2/2) - exploring XML
Google SVG Search I
More search parameters
The following parameters handle scrolling through the result set, the character encoding of documents, and several search options:
Parameter | Value | Description |
---|---|---|
start | 0 | The offset into the result set |
maxResults | 10 | The number of elements to be returned |
filter | false | show similar results |
restrict | '' | Restriction by country or topic |
safeSearch | false | show 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: https://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
URL: https://www.webreference.com/xml/column55/2.html
Created: Apr 29, 2002
Revised: Apr 29, 2002