In [1]:
#!/usr/bin/env python
from googleads import adwords
In [2]:
def get_accounts(client, country):
managed_customer_service = client.GetService('ManagedCustomerService', version='v201609')
selector = {
'fields': ['CustomerId', 'Name']
}
account_ids = []
page = managed_customer_service.get(selector)
if 'entries' in page and page['entries']:
for account in page['entries']:
if str(account['name']).startswith(country + '_') and 'jobseeker' in str(account['name']) \
and '_aed_' not in str(account['name']) and '_app' not in str(account['name'])\
and '_display_' not in str(account['name']) and '_content_' not in str(account['name']):
#print account['name'], account['customerId'], str(account['customerId'])
account_ids.append(str(account['customerId']))
return account_ids
In [3]:
adwords_client = adwords.AdWordsClient.LoadFromStorage()
In [4]:
get_accounts(adwords_client, 'uy')
Out[4]:
In [5]:
countries = ['in', 'us', 'uk', 'mx', 'id', 'jp', 'it', 'za', 'de', 'fr',
'br', 'nl', 'ca', 'ru', 'es', 'au', 'tr', 'pl', 'vn', 'ae',
'ch', 'be', 'sg', 'hk', 'ph', 'tw', 'ie', 'my', 'hu', 'se',
'pe', 'ar', 'ua', 'pt', 'at', 'cz', 'pk', 'nz', 'kr', 'eg',
'th', 'qa', 'dk', 'cr', 'pa', 'co', 'ma', 'bh', 'ng', 'no',
'ec', 'lu', 'fi', 'sa', 'uy']