python - 使用 Python 检查 Adwords 帐户中是否已存在标签?

标签 python google-ads-api

我需要检查我的 Adwords 帐户中是否已存在标签。我正在使用 Python 并为此使用 Adwords API。 我使用以下代码创建了一个标签。在创建这个标签之前,我想检查这个标签是否已经存在,然后不再创建它。

label_service = client.GetService('LabelService', version='v201409')
###Code here to check if 'MyLabel' already exist - please suggest
operations = [{
                'operator': 'ADD',
                'operand': {'xsi_type': 'TextLabel',
                'name' : 'MyLabel',
                'status': 'ENABLED'}
                }]
result = label_service.mutate(operations)

我可以看到通过 LabelService 的 get 操作我可以获得指定条件的标签。 但是我无法正确指定 serviceSelector 参数。

最佳答案

我有同样的问题,如果你像这样运行 get 而不是 mutate:

label_service.get({'fields': ['LabelId', 'LabelName', 'LabelStatus', 'LabelAttribute']})

它将返回一个对象,其中包含帐户中所有现有标签及其 ID 等。

无论如何,我只是对其进行了测试,它不会让您创建一个已经存在的标签,因此您不必担心。

关于python - 使用 Python 检查 Adwords 帐户中是否已存在标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27948658/

相关文章:

google-analytics - 如何在 VueJS 中跟踪 Google Analytics/Adwords 转化

php - Adwords API PHP 示例,用于获取相关关键字的搜索量

python - 对 FITS 图像过采样后从 ra、dec 获取像素坐标

Python:二进制到十进制转换

python - keras:如何编写自定义损失函数以将帧级预测聚合到歌曲级预测

ios - 谷歌广告在 iOS 中的正确行为

java - 针对测试 MCC 帐户(创建帐户)进行测试时出现 AuthorizationError.USER_PERMISSION_DENIED

python - Django:如何更改 PyDev 中的包名称

python - 实现简单 FSM 的 Pythonic 方法是什么?

php - 谁能帮我从 Google Ads API 调试 "proto descriptor was previously loaded"