Andre replies that you are referencing the API in the right place. Since your question was specific to python, let me show you a basic approach to creating your submitted search url in python. In this example, you can access content searches in just a few minutes after you sign up for the free Google API key.
ACCESS_TOKEN = <Get one of these following the directions on the places page> import urllib def build_URL(search_text='',types_text=''): base_url = 'https://maps.googleapis.com/maps/api/place/textsearch/json' # Can change json to xml to change output type key_string = '?key='+ACCESS_TOKEN # First think after the base_url starts with ? instead of & query_string = '&query='+urllib.quote(search_text) sensor_string = '&sensor=false' # Presumably you are not getting location from device GPS type_string = '' if types_text!='': type_string = '&types='+urllib.quote(types_text) # More on types: https://developers.google.com/places/documentation/supported_types url = base_url+key_string+query_string+sensor_string+type_string return url print(build_URL(search_text='Your search string here'))
This code will create and print a URL that searches for everything you put in the last line, replacing "Your search string is here." You need to create one of these URLs for each search. In this case, I printed it so that you can copy and paste it into the address bar of the browser, which will give you the return (in the browser) of the JSON text object in the same way as you will get when your program sends this URL. I recommend using the python query library to get this in your program, and you can do this by simply returning the returned url and doing this:
response = requests.get(url)
Next, you need to analyze the JSON response returned, which you can do by converting it using the json library (find json.loads for example). After running this answer through json.loads, you will have a good python dictionary with all your results. You can also paste this return (for example, from a browser or a saved file) into the JSON online viewer to understand the structure when you write code to access the dictionary that json.loads exits.
Please feel free to post more questions if some of this is not clear.
source share