
72 GOOGLE APPS HACKS
HaCK 27:
Screenscrape bits and pieces from any web page for automated
inclusion in your spreadsheets.
Google Spreadsheets offers you a set of default functions to look up nancial data, or trivia from
their Q&A database . But you can go beyond this feature and access custom data from any
web page, such as a list of links from a blog, or a list of titles or ISBN numbers from a bookseller’s
web site.
There are four key functions that can import external web data: importXml, importData, importHtml,
and googleReader. The most exible of these is importXml, as it turns any kind of HTML into
structured data.
Suppose that you want to automatically add a list of book titles on the subject of extreme sports.
Head over to a bookseller’s web site, like Barnes & Noble (http://barnesandnoble.com) and perform
a search for “extreme sports”; copy the address of the results page, shown in Figure 3-24. This URL
might look like the following:
http://search.barnesandnoble.com/booksearch/results.asp?WRD=extreme+sports
Now you hold the rst part to successfully use the importXML function: the URL of the source page.
The second part of the equation is to tell your spreadsheet specically which HTML part of that
page you want, by using XPath, a language for specifying subsets of an XML (or XHTML) document.
Open the HTML source of the Barnes & Noble page ...