Hi,
It's not you - it's the example. :)
The printing section isn't navigating deeply enough through the object
hierarchy. If you change lines 78 and 79 from:
for attribute in result['data']:
attributes[attribute['key']] = attribute['value']
to:
for attribute in result['data']:
attribute_value = attribute['value']
if 'value' in attribute_value:
attributes[attribute['key']] = attribute_value['value']
else:
attributes[attribute['key']] = []
then the example should print values as expected. I'll work on getting the
example fixed in an upcoming release. Thanks for pointing this out!
Cheers,
Josh, AdWords API Team
On Monday, December 1, 2014 4:17:05 AM UTC-5, OB1 wrote:
>
> Hi,
>
> I've been using looking at the sample code to generate keyword idea
> provided here:
>
>
> https://github.com/googleads/googleads-python-lib/blob/master/examples/adwords/v201409/optimization/get_keyword_ideas.py
>
> Everything works fine except the parsing of the response data which
> doesn't look correct to me. Can someone clarify if this is expected
> behaviour?
>
> This is the code provided to parse and print out the results:
>
> if 'entries' in page: for result in page['entries']: attributes = {} for
> attribute in result['data']: attributes[attribute['key']] = attribute['
> value'] print ('Keyword with \'%s\' text and average monthly search
> volume ' '\'%s\' was found with Products and Services categories: %s.' %
> (attributes['KEYWORD_TEXT'], attributes['SEARCH_VOLUME'], attributes['
> CATEGORY_PRODUCTS_AND_SERVICES']))
>
> From this, I would expect to get something along the lines of following:
>
> Keyword with [my keyword] text and average monthly search volume [X] was
> found with Products and Services categories: [A, B, C].
>
> What I'm actually seeing is more like this with the full attribute
> information:
>
> Keyword with '(StringAttribute){
> Attribute.Type = "StringAttribute"
> value = "banff"
> }' text and average monthly search volume '(LongAttribute){
> Attribute.Type = "LongAttribute"
> value = 135000
> }
> ...
>
> I'm certain I'm missing something obvious here so any pointers in the
> right direction would be most appreciated.
>
>
>
> Ogilvy & Mather Group (Holdings) Ltd is a company registered in England
> and Wales with registration number 45810.
> Registered office: 10 Cabot Square, Canary Wharf, London E14 4QB. VAT
> number: GB 189 8416 47
>
>
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at http://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/e54e1b47-0f78-47e8-9c38-2799d1536499%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.