
155
HaCK 63:
Fetch content from any other web site in near real time to stay
up-to-date on iGoogle.
Some sites offer an API (Application Programming Interface) for you to grab their data. But using
so-called screenscraping, you can grab almost any web site’s content—independent of whether the
site offers an API to developers. This hack comes in handy to collect snippets of information from
dynamically updated, information-heavy web sites.
The iGoogle framework makes fetching web site content very easy through the _IG_FetchContent()
function. This function accepts two parameters: one is the URL to be fetched, and the other is the
function to execute when the content is returned.
As an example, let’s say you want to measure the number of times blogs recently linked to your
company home page (or your personal blog, or any other web site). You can use the Google Gadget
Editor to create a new gadget , as shown in Figure 6-20. The rst step is to set up the
“skeleton” of your gadget, and include a “Loading” message:
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Fetch Content Example" />
<Content type="html"><![CDATA[
<p id="content">Loading...</p>
]]></Content>
</Module>
HaCK
# 63
- ADD GOOGLE NEWS TO IGOOGLE
Scripting an iGoogle module using the Google Gadget Editor