Feb-07-2019, 01:38 PM
Hi, is it possible to search the results "where am I" or "places nearby me" using google API in python
Right now mentioned below Python code is searching the place only.
like when I am mentioning "Hotel in California" then places list has been mentioned in the python shell
But while searching the query "where am i" it does not give any list.
Your leads on this will be a great help
Right now mentioned below Python code is searching the place only.
like when I am mentioning "Hotel in California" then places list has been mentioned in the python shell
But while searching the query "where am i" it does not give any list.
# importing required modules
import requests, json
# enter your api key here
api_key = 'Your_API_key'
# url variable store url
url = "https://maps.googleapis.com/maps/api/place/textsearch/json?"
# The text string on which to search
query = input('Search query: ')
# get method of requests module
# return response object
r = requests.get(url + 'query=' + query +
'&key=' + api_key)
# json method of response object convert
# json format data into python format data
x = r.json()
# now x contains list of nested dictionaries
# we know dictionary contain key value pair
# store the value of result key in variable y
y = x['results']
# keep looping upto lenght of y
for i in range(len(y)):
# Print value corresponding to the
# 'name' key at the ith index of y
print(y[i]['name'])Note: Right now, I am only using Google maps API, Do I have to use any other API also?Your leads on this will be a great help
