Hi!

I'm running on Python and I am having a little bit of trouble with the 
display results portion of the script. Instead of printing the results, I 
wanted to save the keyword and search volume into a list to use elsewhere. 
I am trying to just store the variables and I'm getting this error: 

sv *undefined*, *attributes* = {'KEYWORD_TEXT': 'seo'}

*KeyError*: 'SEARCH_VOLUME' 
      args = ('SEARCH_VOLUME',) 
      with_traceback = <built-in method with_traceback of KeyError object>


Here is the portion of the script:
# Display results.
    if 'entries' in page:
      keyword_list = []
      for result in page['entries']:
        attributes = {}
        for attribute in result['data']:
          print(attribute)
          attributes[attribute['key']] = getattr(attribute['value'], 'value'
, '0')
          kw = attributes['KEYWORD_TEXT']
          sv = attributes['SEARCH_VOLUME']
        #print ('Keyword with "%s" text and average monthly search volume '
        #       '"%s".'
        #       % (attributes['KEYWORD_TEXT'], attributes['SEARCH_VOLUME']))
        print(kw)
    else:
      print ('No related keywords were found.')


When I don't try and save them as variables, or into a list, and just print 
them, it works. 

Please advise?

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/deba3d84-f85c-4461-9e29-f5cf62f275d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • Get_key... Stephen Barrett
    • RE... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum

Reply via email to