Sub topic 13
Limits, terms of use, and responsible collection
This chapter assumes you have read the chapters on autocomplete expansion and on collecting suggestions with a short script. You should be comfortable running the Python examples from those chapters. Here the focus changes from how to collect ideas to how much to collect, and whether you should.
Why limits matter
Autocomplete and People also ask (PAA) are features of a public product. Google built them for people typing into a search box. They were not built as a data feed. Three limits follow from that.
- No guarantees. The suggestion endpoint used in the script chapter is unofficial and undocumented. Google can change its format, block requests, or remove it without notice.
- No volume data. A suggestion tells you that people type something. It does not tell you how often.
- No stable results. Location, language, and personalization change what you see, so a collected list is a snapshot, not a fact.
Terms of use and automated access
Google's terms of service restrict automated access to its services. Scraping the search results page, which includes PAA boxes, is the more clearly restricted activity. Read the current terms yourself before you build anything repeatable. This chapter is not legal advice, and the rules may differ for personal, commercial, and client work.
A practical way to rank your options, from safest to riskiest:
| Approach | Risk | Notes |
|---|---|---|
| Typing queries by hand and noting suggestions | Lowest | Slow, but it is ordinary use |
| A few scripted autocomplete requests at a low rate | Moderate | Unofficial endpoint, may break or be blocked |
| Scraping PAA boxes or result pages at scale | Highest | Likely to trigger blocks and conflicts with the terms |
| A licensed SERP or keyword data provider | Low | Costs money, but has documented terms and support |
If you need volume or PAA data on a regular basis, a licensed provider is usually the better choice than maintaining your own scraper.
Collecting responsibly
Keep your request rate low, stop when you are blocked, and collect only what you need. The function below wraps any fetch function with a pause, a hard cap on requests, and a stop on errors.
import time
import requests
SUGGEST_URL = "https://suggestqueries.google.com/complete/search"
def suggest(query, language="en"):
response = requests.get(
SUGGEST_URL,
params={"client": "firefox", "q": query, "hl": language},
timeout=10,
)
response.raise_for_status()
return response.json()[1]
def polite_collect(queries, fetch, max_requests=30, delay=2.0):
results = {}
for count, query in enumerate(queries):
if count >= max_requests:
print("Request cap reached, stopping.")
break
try:
results[query] = fetch(query)
except requests.RequestException as error:
print(f"Stopping after an error on {query!r}: {error}")
break
time.sleep(delay)
return results
queries = ["cold brew", "cold brew for", "cold brew vs"]
print(polite_collect(queries, suggest))Three habits in this code are worth copying:
- A cap on total requests, so a loop bug cannot send thousands of calls.
- A delay between calls, longer than the one-second pause in the earlier example if you run it often.
- A stop on the first error, rather than retrying in a tight loop. A
429or a block page means you should wait, not push harder.
Handling the data you collect
- Suggestions are short queries typed by many people, but they can still contain names or private details. Do not publish raw lists without reviewing them.
- Store the date, language, and location of each collection run. Without these, you cannot explain why a later run looks different.
- Cache results so you do not request the same query twice.
Exercise
Your script is returning HTTP 429 errors after about 80 requests. A teammate suggests adding a pool of proxy addresses so the requests look like they come from different users. What should you do instead, and why?
Show answer
Stop the script, wait, and lower the rate by adding a longer delay and a request cap. If you need that volume regularly, switch to a licensed data provider. Proxies would be an attempt to evade a block, which makes the terms-of-use problem worse and is not responsible collection.
Exercise
Name two things you should record with every collection run, and say why.
Show answer
Record the date and the language and location settings. Autocomplete and PAA change over time and by place, so without these details you cannot compare runs or explain differences between them.