98 Part II — Instant Gratification
Within some limitations Google can be tricked to do the geocoding for you right across the
world using the database that Google Local uses to look up and generate information. The way
you do this is to send a request to the Google service that would normally look up the informa-
tion for you within a web page. You then “scrape” the web page for the information you were
looking for.
For example, if you visit Google Local and enter New York, you get the web page shown in
Figure 6-1.
FIGURE6-1: New York within Google Local.
If you examine the raw HTML from the page that was generated, the geocode information can
be extracted from the JavaScript component of the page. Scraping for the data works because
the page itself contains a map, and that includes the JavaScript that centers the map on the
address entered. The relevant fragment from the page can be seen in Listing 6-2. The element
you are looking for is the GLatLng()function call.
Listing 6-2:Scraping Information from Google
<html><head><title>Google Local - New York</title><script>
...
</style><script src=”/maps?file=api&v=2&async=1&hl=en” ;