0

I'm using Google Maps APi places search in python

import urllib
import urllib.request
import json

googleGeocodeUrl = 'https://maps.googleapis.com/maps/api/place/textsearch/json?query='
keyword = "hospitales"
geolocation = "&location=-12.135,-77.023&radius=5000"
APIKEY = '&key='+'AIzaSyg5v17Ik'

url = googleGeocodeUrl + keyword + geolocation + APIKEY
print(url)

url = googleGeocodeUrl + keyword + geolocation + APIKEY
json_response = urllib.request.urlopen(url)
search = json_response.read().decode('utf-8')
searchjson = json.loads(search)

export = open('hopital.csv','w')
for place in searchjson['results']:
    print(place['name'])
    print(place['geometry']['location'])
export.write(place['name']+','+str(place['geometry']['location']['lng'])\
 +','+str(place['geometry']['location']['lat'])+'\n')
export.close() 

I want my code to make some kind of loop where it's gonna return results for more than one geographic coordinate at the time. How can I achieve that? Any code sample that could help me?

Simon GIS
  • 1,045
  • 2
  • 18
  • 37
  • my guess would be that if you're only getting 20 results, you'll want to change the request url, not your python code. – Jonas May 31 '18 at 03:20
  • Possible duplicate of [Obtaining more than 20 results with Google Places API](https://stackoverflow.com/questions/6965847/obtaining-more-than-20-results-with-google-places-api) – Jonas May 31 '18 at 03:20
  • @Jonas how can I addapt mu url request to more then 20 results? – Simon GIS May 31 '18 at 07:35
  • See this post: https://stackoverflow.com/questions/9614258/how-to-get-20-result-from-google-places-api – Jonas May 31 '18 at 07:36

0 Answers0