Hi,

Can you please provide your API request and response so I can see if there
are any issues through *reply privately to author*?

Thanks,
Anthony
Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

On 04/18/19 03:40:21 [email protected] wrote:

I am using the google ads api for keyword research on my website but it
takes too long.

Simply getting the data from the google database takes 6 seconds. I have
removed anything that modifies the data so I am sure that it takes 6
seconds to get the data.

This is the code for getting the keyword volume, competition and ideas.


import csv
import time
import suds
import re
from googleads import adwords
import os


class Ads(object):
   def __init__(self, keywords):
      self.num_calls = 0
      self.langID = 1000
      self.locID = 2840

self.adwords_client = adwords.AdWordsClient.LoadFromStorage('googleads.yaml')

      self.before_estimate = keywords

      # set up queries for search volume
list_of_calls = [self.before_estimate[i:i + 200] for i in range(0, len(self.before_estimate), 200)]
      self.num_calls = len(list_of_calls)
print("Get ready for ", self.num_calls, "calls and approximately ", self.num_calls * 50, "seconds.")

      self.results = self.get_estimate_search_volume(list_of_calls)

def api_call_function(self, keyword_list, langID, locID, count, requestType):

targeting_idea_service = self.adwords_client.GetService('TargetingIdeaService', version='v201809')

      offset = 0
      PAGE_SIZE = 100

      selector = {
         'searchParameters': [

            {
               'xsi_type': 'RelatedToQuerySearchParameter',
               'queries': keyword_list
            },
            {

               'xsi_type': 'LanguageSearchParameter',
               'languages': [{'id': langID}]
            },
            {
               'xsi_type': 'LocationSearchParameter',
               'locations': [{'id': locID}]
            },
            {
               # Network search parameter (optional)
               'xsi_type': 'NetworkSearchParameter',
               'networkSetting': {
                  'targetGoogleSearch': True,
                  'targetSearchNetwork': False,
                  'targetContentNetwork': False,
                  'targetPartnerSearchNetwork': False
               }
            },
            {
               'xsi_type': 'IdeaTextFilterSearchParameter',
               'included': keyword_list
            }

         ],
         'ideaType': 'KEYWORD',
         'requestType': requestType,
'requestedAttributeTypes': ['KEYWORD_TEXT', 'SEARCH_VOLUME', 'COMPETITION'],
         'paging': {
            'startIndex': str(offset),
            'numberResults': count
         }
      }

      page = targeting_idea_service.get(selector)

      # Create dictionary with keyword, search volume pair
      all_results = {}
      for result in page['entries']:
         for attribute in result['data']:
            if attribute['key'] == "KEYWORD_TEXT":
               word = attribute['value']['value']
            if attribute['key'] == "SEARCH_VOLUME":
               volume = attribute['value']['value']
            if attribute['key'] == "COMPETITION":
               competition = attribute['value']['value']
         if competition == 0.0 or competition is None:
            pass
         else:
            all_results[word] = [volume, competition]

      return all_results

   def api_call_error_handling(self, errors, current_call, i):
      def save_and_delete_keywords(keyword_file, error_lines):
         # delete bad keywords and log those deleted
         deleted_keyword_file = "deleted_" + keyword_file
         deleted_list = []
         with open(deleted_keyword_file, "a") as d_file:
            for bad_words in error_lines:
               deleted = current_call

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads 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 and Google Ads 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/1a0o73g0000000018ha4i80039ms82y6smj0dph6go30c1g68r36c1k%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
  • Google ... Daj Katal
    • RE... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
    • Re... Sergei Kim

Reply via email to