Google's Autocomplete function is populated by Google based on the vast knowledge they have on their users' search pattern. Often, they are based on searches often made by other users.
Due to that, we can leverage that to build a powerful keyword tool that can be useful for your paid search strategy, SEO planning, and other marketing research and planning.
In fact, there are paid keyword tools out there that are based on leverage Google's Autocomplete function.
Here, I'll show you how you can build a powerful keyword tool with a few lines of Python code. All you need after is a root keyword.
Apart from it being totally free, you can do many powerful things when you have all the results in your Python console, which I might expand on in future posts.
First off, we'll use the suggestqueries.google.com link to obtain the autocomplete results. Note that this is subject to Google keeping this link alive.
def autocomplete(query):
'''
USING GOOGLE SEARCH AUTOCOMPLETE
'''
from fake_useragent import UserAgent
ua = UserAgent()
import time
from random import randint
time.sleep(randint(0, 2))
import requests, json
URL= 'http://suggestqueries.google.com/complete/search?client=firefox&q={0}&hl=en'.format(query)
headers = {'User-agent':ua.random}
response = requests.get(URL, headers=headers)
result = json.loads(response.content.decode('utf-8'))
return result[1]
As this is a regular request's response via your device, note that the result is affected by your geographic location. Using a VPN might help you get results for other markets.
The "autocomplete" function will be the core engine of the code.
The Google Autocomplete suggestion is based on the partial searches you keyed in. Hence, here we'll build a huge list of possible permutations via partial words.
In the snapshot below, you can see the various suggestions that are generated via partial searches.
Hence, we'll leverage another function to build the permutations via running the "autocomplete" function for:
def generate_keywords(query):
'''
Function to generate a large number of keyword suggestions
'''
seed = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
print('Grabbing suggestions... ' + str(query))
first_pass = autocomplete(query)
second_pass = [autocomplete(x) for x in first_pass]
flat_second_pass = []
flat_second_pass = [query for sublist in second_pass for query in sublist]
third_pass = [autocomplete(query + ' ' + x) for x in seed]
flat_third_pass = []
flat_third_pass = [query for sublist in third_pass for query in sublist]
keyword_suggestions = list(set(first_pass + flat_second_pass + flat_third_pass))
keyword_suggestions.sort()
print('SUCCESS!')
return keyword_suggestions
Using those two functions, you're now ready to generate your keywords.
You may choose to have a list of root keywords by passing a list to the "generate_keywords" function
keyword_list = [
'teleconference',
'video conference',
'web conference'
]
keywords = [auto_suggest.generate_keywords(q) for q in keyword_list]
keywords = [query for sublist in keywords for query in sublist] # to flatten
keywords = list(set(keywords)) # to de-duplicate
From my end, the three root keywords above generated 1,008 suggestions.
If you have an AdWords API key, you may pass those suggestions into the API to get the search stats e.g. estimated CPC, monthly search volume.
Since it's on Python, you can do all sorts of manipulation to the data. Here, I've built an interactive network graph on the keyword pattern for visual analysis.
Like the post? Consider donating to fund the maintenance of this website: