I have a simple function to get the search volume for keywords, however in the last few days we noticed some strange behaviour, when the following keyword is sent the volume is correctly returned:
words = ['test']
however when this keyword is sent the results are empty:
words = ['arutz']
even more when these words are sent together the results are empty as well:
words = ["test","arutz"]
(if I manually enter these in the keyword planner I do get search volumes for each word)
this is the function for getting the search volume:
def TestVolume(words):
PAGE_SIZE = 100
# Initialize appropriate service.
targeting_idea_service = client.GetService('TargetingIdeaService', version='v201705')
# Construct selector object and retrieve related keywords.
offset = 0
selector = {
'searchParameters': [
{
'xsi_type': 'RelatedToQuerySearchParameter',
'queries': words
},
],
'ideaType': 'KEYWORD',
'requestType': 'STATS',
'requestedAttributeTypes': ['KEYWORD_TEXT', 'SEARCH_VOLUME'],
'paging': {
'startIndex': str(offset),
'numberResults': str(PAGE_SIZE)
}
}
more_pages = True
while more_pages:
page = targeting_idea_service.get(selector)
# Display results.
if 'entries' in page:
for result in page['entries']:
attributes = {}
for attribute in result['data']:
attributes[attribute['key']] = getattr(attribute['value'], 'value','0')
print ('Keyword \'%s\' average monthly search volume '
'\'%s\n'
% (attributes['KEYWORD_TEXT'],
attributes['SEARCH_VOLUME']))
print attributes
word = {}
word[attributes['KEYWORD_TEXT']] = attributes['SEARCH_VOLUME']
else:
print 'No related keywords were found.'
offset += PAGE_SIZE
selector['paging']['startIndex'] = str(offset)
more_pages = offset < int(page['totalNumEntries'])