Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

Chapter 4 — The Google Web API 59


Table 4-4: Search Limitations

Item Limit

Maximum query string length 2,048 bytes
Maximum number of words in the query 10
Maximum number of “site:” terms 1
Maximum number of results per query 10
Maximum value of start index and result size 1,000

If your search obtains more than 1,000 results, you can obtain only the first 1,000 — and your
query string is probably not specific enough to return the information you are looking for any-
way. Narrow down your search and try again with a different query string.


As you can see in Table 4-4, you can see only 10 results at a time from Google. The initial
search, if you don’t specify otherwise, will return the first 10 results. To see subsequent results,
you must specify an alternative starting index with multiple requests. This is called paging.


For example, imagine that you search for plumbers in Stamford. Your first query returns the
first 10 items. From this first search, you can extract the number of the expected results by
looking at the value of the estimatedTotalResultsCountelement of the base data. If the
value of this is 87 and you want to obtain the remainder of the results, you must also perform
the following searches:


Plumbers in Stamford starting at index 11.
Plumbers in Stamford starting at index 21.

Plumbers in Stamford starting at index 31.
Plumbers in Stamford starting at index 41.

Plumbers in Stamford starting at index 51.
Plumbers in Stamford starting at index 61.

Plumbers in Stamford starting at index 71.
Plumbers in Stamford starting at index 81.

With these eight requests, you’ve finally got all of the information you need. Well, you’ve got
information, anyway; to determine whether it is what you wanted, you must examine the
results in more detail.

Free download pdf