def getRequest(selector, targeting_idea_service):
page = targeting_idea_service.get(selector)
while True:
try:# Getpage = targeting_idea_service.get(selector)# Display results.if 'entries' in page:for result in page['entries']:attributes = {}for attribute in result['data']:attributes[attribute['key']] = getattr(attribute['value'], 'value', '0')#print resultmoney = {}money = attributes['AVERAGE_CPC']cpc = money['microAmount']out = ""out = "{'" + str(attributes['KEYWORD_TEXT']) + "': {'CPC': " + str(cpc) + ", 'SV': " + str(attributes['SEARCH_VOLUME']) + ", 'CR': " + str(attributes['COMPETITION']) + "}}"print outelse:print 'No related keywords were found.'
except suds.WebFault as detail:
print detailprint "Sleeping WebFault"time.sleep(31)
continue
except Exception as e:
print eprint "Sleeping"time.sleep(31)continue
break
Traceback (most recent call last):
File "cpc2.py", line 165, in <module>
main(sys.argv[1:])
File "cpc2.py", line 149, in main
getRequest(selector, targeting_idea_service)
File "cpc2.py", line 52, in getRequest
page = targeting_idea_service.get(selector)
File "/Library/Python/2.7/site-packages/googleads/common.py", line 700, in MakeSoapRequest
*[_PackForSuds(arg, self.suds_client.factory) for arg in args])
File "/Library/Python/2.7/site-packages/suds/client.py", line 521, in __call__
return client.invoke(args, kwargs)
File "/Library/Python/2.7/site-packages/suds/client.py", line 581, in invoke
result = self.send(soapenv)
File "/Library/Python/2.7/site-packages/suds/client.py", line 613, in send
reply = self.options.transport.send(request)
File "/Library/Python/2.7/site-packages/googleads/util.py", line 98, in PatchedHttpTransportSend
fp = self.u2open(u2request)
File "/Library/Python/2.7/site-packages/suds/transport/http.py", line 132, in u2open
return url.open(u2request, timeout=tm)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 437, in open
response = meth(req, response)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 550, in http_response
'http', request, response, code, msg, hdrs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 475, in error
return self._call_chain(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 558, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: Internal Server Error
Traceback (most recent call last):
File "cpc2.py", line 165, in <module>
main(sys.argv[1:])
File "cpc2.py", line 149, in main
getRequest(selector, targeting_idea_service)
File "cpc2.py", line 52, in getRequest
page = targeting_idea_service.get(selector)
File "/Library/Python/2.7/site-packages/googleads/common.py", line 647, in MakeSoapRequest
raise e
suds.WebFault: Server raised fault: '[RateExceededError <rateName=RATE_LIMIT, rateKey=null, rateScope=ACCOUNT, retryAfterSeconds=30>]'