I'm conducting distance queries using the google API
for r in cursorConsulta:
googleGeocodeUrl = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location='
punto = str(r[1])+','+str(r[0])
id = r[2]
#radioBusqueda = r[3]
radio = '&radius=4000'
clave = '&keyword=' + 'anses'
APIKEY = '&key=' + '****'
url = googleGeocodeUrl + punto + radio + clave + APIKEY
print(url)
json_response = urllib.request.urlopen(url)
busqueda = json_response.read().decode('utf-8')
busquedajson = json.loads(busqueda)
result = busquedajson['status']
When the api returns the status
OVER_QUERY_LIMIT
Create a new api key to be able to process again
if result=="OVER_QUERY_LIMIT":
googleGeocodeUrl = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location='
punto = str(r[1])+','+str(r[0])
id = r[2]
#radioBusqueda = r[3]
radio = '&radius=4000'
clave = '&keyword=' + 'anses'
APIKEY = '&key=' + '****'
url = googleGeocodeUrl + punto + radio + clave + APIKEY
print(url)
json_response = urllib.request.urlopen(url)
busqueda = json_response.read().decode('utf-8')
busquedajson = json.loads(busqueda)
The question is as follows, enter the first query of the api and reprocess the allowed amount, when it reaches its maximum it enters the if result == "OVER_QUERY_LIMIT": and reprocesses , now when you regenerate the OVER_QUERY_LIMIT message of the second KEY API, how can I do it so that the application will have it if it does not continue running with the query message exceeded.