I wanted to know what people actually type before a trip to China. Not what I assumed, and not what travel blogs cover β what goes into the box.
Google does not sell that data cheaply. But it does hand out its autocomplete endpoint for free, and that endpoint returns the phrases real people typed, ordered by how often they type them.
So I scraped my own question into it.
The harvest
Three layers, about 2,560 requests:
# 1. seed phrases SEEDS = [ 'china' , 'china travel' , 'china visa' , 'china hotel' , 'china sim card' , . . . ]
# 2. question prefixes β this is where intent lives PREFIXES = [ 'how to' , 'how much' , 'can i' , 'do i need' , 'best' , 'cheapest' , . . . ]
# 3. alphabet soup on the shortest results for seed in top_50_shortest : for ch in 'abcdefghijklmnopqrstuvwxyz0123456789' : yield seed + ' ' + ch
Enter fullscreen mode
Exit fullscreen mode
def suggest ( q ) : url = f 'https://suggestqueries.google.com/complete/search?client=firefox&hl=en&gl=us&q={quote(q)}' return json .β¦