Hello I'm using the targeting keyword Idea api to extract the search
volume of past searches of a speciifc word monthly. In the UI I can set the
date range and extract the month by month stats for the specific country
for past three years. In API I can get the annual stats. However when I
want to get the stats for three years month by month I'm nt able to
correctly use the date range feature in the python API of the Google
ADWORDS. I get the below error
TypeNotFound: Type not found: 'DateRange':
This is my script. Please help
from googleads import adwords
PAGE_SIZE = 100
start_date = '20140101'
end_date = '20140101'
def main(client):
# Initialize appropriate service.
targeting_idea_service = client.GetService(
'TargetingIdeaService', version='v201702')
# Construct selector object and retrieve related keywords.
offset = 0
selector = {
'searchParameters': [
{
'xsi_type': 'RelatedToQuerySearchParameter',
'queries': ['TRUMP DUMP']
},
{
# Language setting (optional).
# The ID can be found in the documentation:
#
https://developers.google.com/adwords/api/docs/appendix/languagecodes
'xsi_type': 'LanguageSearchParameter',
'languages': [{'id': '1000'}]
},
{
# Network search parameter (optional)
'xsi_type': 'NetworkSearchParameter',
'networkSetting': {
'targetGoogleSearch': True,
'targetSearchNetwork': False,
'targetContentNetwork': False,
'targetPartnerSearchNetwork': False
}
}
],
'ideaType': 'KEYWORD',
'requestType': 'STATS',
'requestedAttributeTypes': ['KEYWORD_TEXT', 'SEARCH_VOLUME',
'TARGETED_MONTHLY_SEARCHES'],
'paging': {
'startIndex': str(offset),
'numberResults': str(PAGE_SIZE)
},
'DateRange':{
'min': '20140101',
'max': '20170101'
}
}
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 with \'%s\' text and average monthly search volume '
'\'%s\' was found with Products and Services categories: %s.'
% (attributes['KEYWORD_TEXT'],
attributes['SEARCH_VOLUME'],
attributes['TARGETED_MONTHLY_SEARCHES']))
print
else:
print 'No related keywords were found.'
offset += PAGE_SIZE
selector['paging']['startIndex'] = str(offset)
more_pages = offset < int(page['totalNumEntries'])
if __name__ == '__main__':
# Initialize client object.
adwords_client = adwords.AdWordsClient.LoadFromStorage()
main(adwords_client)
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/0f177e91-0948-47da-90df-e95dbf0d35f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.