Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main(client):
# Initialize appropriate service.
campaign_service = client.GetService('CampaignService', version='v201802')
# Construct query and get all campaigns.
query = (adwords.ServiceQueryBuilder()
.Select('Id', 'Name', 'Status')
.Where('Status').EqualTo('ENABLED')
.OrderBy('Name')
.Limit(0, PAGE_SIZE)
.Build())
for page in query.Pager(campaign_service):
# Display results.
if 'entries' in page:
for campaign in page['entries']:
print ('Campaign with id "%s", name "%s", and status "%s" was '
'found.' % (campaign['id'], campaign['name'],
campaign['status']))
else:
print 'No campaigns were found.'
trial_operation = {'operator': 'SET', 'operand': trial}
# Update the trial.
trial = trial_service.mutate([trial_operation])['value'][0]
# Graduation is a synchronous operation, so the campaign is already ready. If
# you promote instead, make sure to see the polling scheme demonstrated in
# add_trial.py to wait for the asynchronous operation to finish.
print ('Trial ID %d graduated. Campaign %d was given a new budget ID %d and '
'is no longer dependent on this trial.' % (
trial['id'], trial['trialCampaignId'], budget_id))
if __name__ == '__main__':
# Initialize client object.
adwords_client = adwords.AdWordsClient.LoadFromStorage()
main(adwords_client, TRIAL_ID)
# Display results.
for ad in ads['value']:
print ('New HTML5 Ad with id \'%s\' and of display url \'%s\' was added.'
% (ad['ad']['id'], ad['ad']['displayUrl']))
def GetBase64EncodedHTML5ZipFromUrl(url):
"""Retrieve zip file from the given URL."""
response = urllib2.urlopen(url)
return base64.b64encode(response.read())
if __name__ == '__main__':
# Initialize client object.
adwords_client = adwords.AdWordsClient.LoadFromStorage()
main(adwords_client, AD_GROUP_ID)
print ('Keyword ID \'%d\', type \'%s\', text \'%s\', and match type '
'\'%s\' was found.' % (
keyword['criterion']['id'],
keyword['criterion']['type'],
keyword['criterion']['text'],
keyword['criterion']['matchType']))
else:
print 'No 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, ADGROUP_ID)
}
]
conversion_trackers = conversion_tracker_service.mutate(operations)
# Display results.
for conversion_tracker in conversion_trackers['value']:
print ('Conversion tracker with id \'%s\', name \'%s\', status \'%s\' '
'and category \'%s\' and snippet \n\'%s\'\n was added.\n' %
(conversion_tracker['id'], conversion_tracker['name'],
conversion_tracker['status'], conversion_tracker['category'],
conversion_tracker['snippet']))
if __name__ == '__main__':
# Initialize client object.
adwords_client = adwords.AdWordsClient.LoadFromStorage()
main(adwords_client)
accounts[account['customerId']] = account
if account['customerId'] not in parent_links:
root_account = account
# Display account tree.
if root_account:
print 'CustomerId, Name'
DisplayAccountTree(root_account, accounts, child_links, 0)
else:
print 'Unable to determine a root account'
else:
print 'No serviced accounts were found'
if __name__ == '__main__':
# Initialize client object.
adwords_client = adwords.AdWordsClient.LoadFromStorage()
main(adwords_client)
'operand': {
'campaignId': draft_campaign_id,
'criterion': criterion
}
}
criterion = campaign_criterion_service.mutate([criterion_operation])[
'value'][0]
print ('Draft updated to include criteria in campaign with ID %d' %
draft_campaign_id)
if __name__ == '__main__':
# Initialize client object.
adwords_client = adwords.AdWordsClient.LoadFromStorage()
main(adwords_client, BASE_CAMPAIGN_ID)
}
}
]
result = ad_group_criterion_service.mutate(operations)
# Display results.
for criterion in result['value']:
print ('Ad group criterion with ad group id \'%s\', criterion id \'%s\', '
'and type \'%s\' was deleted.'
% (criterion['adGroupId'], criterion['criterion']['id'],
criterion['criterion']['Criterion.Type']))
if __name__ == '__main__':
# Initialize client object.
adwords_client = adwords.AdWordsClient.LoadFromStorage()
main(adwords_client, AD_GROUP_ID, CRITERION_ID)
'description': description,
'finalUrls': {'urls': [final_url]},
'price': {
'money': {
'microAmount': price_in_micros,
},
'currencyCode': currency_code
},
'priceUnit': price_unit,
'xsi_type': 'PriceTableRow'
}
if __name__ == '__main__':
# Initialize client object.
adwords_client = adwords.AdWordsClient.LoadFromStorage()
main(adwords_client, CAMPAIGN_ID)
# Create report query.
report_query = ('SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, '
'FinalUrls, Impressions, Clicks, Cost '
'FROM CRITERIA_PERFORMANCE_REPORT '
'WHERE Status IN [ENABLED, PAUSED] '
'DURING LAST_7_DAYS')
print report_downloader.DownloadReportAsStringWithAwql(
report_query, 'CSV', skip_report_header=False, skip_column_header=False,
skip_report_summary=False, include_zero_impressions=True)
if __name__ == '__main__':
# Initialize client object.
adwords_client = adwords.AdWordsClient.LoadFromStorage()
main(adwords_client)