---------------------------------------------------------------------------------------------
Server time:
Wed, 05 May 2021 23:13:14 +0000
---------------------------------------------------------------------------------------
views.py
the code inside the function I'm calling:
---------------------------------------------------------------------------------------
credentials = {
"developer_token": "hide",
"refresh_token": "hide",
"client_id": "hide",
"client_secret":
"hide" }
client = GoogleAdsClient.load_from_dict(credentials)
keyword_texts = ['slippers']
language_id = "1000"
location_ids = "1023191"
customer_id = "4677556196"
def _map_locations_ids_to_resource_names(client, location_ids):
"""Converts a list of location IDs to resource names.
Args:
client: an initialized GoogleAdsClient instance.
location_ids: a list of location ID strings.
Returns:
a list of resource name strings using the given location IDs.
"""
build_resource_name = client.get_service(
"GeoTargetConstantService"
).geo_target_constant_path
return [build_resource_name(location_id) for location_id in location_ids]
keyword_plan_idea_service = client.get_service("KeywordPlanIdeaService")
keyword_competition_level_enum = client.get_type(
"KeywordPlanCompetitionLevelEnum"
).KeywordPlanCompetitionLevel
keyword_plan_network = client.get_type(
"KeywordPlanNetworkEnum"
).KeywordPlanNetwork.GOOGLE_SEARCH_AND_PARTNERS
language_rn = client.get_service(
"LanguageConstantService"
).language_constant_path(language_id)
request = client.get_type("GenerateKeywordIdeasRequest")
request.customer_id = customer_id
request.language = language_rn
request.include_adult_keywords = False
request.keyword_plan_network = keyword_plan_network
request.keyword_seed.keywords.extend(keyword_texts)
keyword_ideas = keyword_plan_idea_service.generate_keyword_ideas(
request=request
)
limit = 20
index = 0
goog_key_tool = []
for idea in keyword_ideas:
goog_key_tool.append(idea.keyword_idea_metrics.avg_monthly_searches)
index += 1
if index == limit:
break
print(goog_key_tool)
--------------------------------------------------------------------------------------