skynyrd
2/16/2017 - 1:18 PM

Google Places spike in Python

Google Places spike in Python

# Google Places, Python
# -*- coding: utf-8 -*-

from googleplaces import GooglePlaces, lang
import ConfigParser


def get_config():
    config = ConfigParser.RawConfigParser()
    config.read('config.cfg')
    return config


def query_the_place(place):
    config = get_config()
    google_places = GooglePlaces(config.get('General', 'GOOGLE_API_KEY'))
    return google_places.autocomplete(input=place, location='istanbul, Turkey', language=lang.TURKISH)


def main():
    print "Enter your maalle:"
    query_result = query_the_place(raw_input())
    print "You are probably in:"
    for prediction in query_result.predictions:
        print prediction.description

        # for term in prediction.terms:
        #     print term['value']


if __name__ == "__main__":
    main()