如何从 google places api for python 的地点 ID 获取地点详情
how to get place details from place id in google places api for python
我正在使用 Google Places API 和 Python 来构建食物的集体智慧应用程序。例如附近有哪些餐厅、评分如何、时间安排等
我在 Python 中执行以下操作:
from googleplaces import GooglePlaces, types, lang
API_KEY = ''
google_places = GooglePlaces(API_KEY)
query_result = google_places.nearby_search(
location='Mumbai', keyword='Restaurants',
radius=1000, types=[types.TYPE_RESTAURANT])
if query_result.has_attributions:
print query_result.html_attributions
for place in query_result.places:
print place.name
print place.geo_location
print place.place_id
它 returns 我是这样的:
Subway
{u'lat': Decimal('19.1156005'), u'lng': Decimal('72.9090715')}
ChIJV2JWaObH5zsRt-FrEb8lrtM
Aroma's Cafe
{u'lat': Decimal('19.116867'), u'lng': Decimal('72.90982199999999')}
ChIJSWijB-bH5zsRVLE5ipsxvHU
Chili's
{u'lat': Decimal('19.1161942'), u'lng': Decimal('72.90909789999999')}
ChIJ4_2UcubH5zsRWMemt2WTsLc
Mainland China
{u'lat': Decimal('19.1154358'), u'lng': Decimal('72.90858159999999')}
ChIJ88dcaObH5zsRWLT4KyCLkI8
The Yellow Chilli
现在我想了解每家餐厅的详细信息(例如他们的评分、评论、时间安排)。如何使用 place_id
检索信息?
参考这个(向下滚动查看文档):
https://github.com/slimkrazy/python-google-places
它有你需要的所有电话。例如:
for place in query_result.places:
place.get_details()
print place.rating
将获得您的每个地点的评分。 github link 中几乎所有内容都适合您:)
我正在使用 Google Places API 和 Python 来构建食物的集体智慧应用程序。例如附近有哪些餐厅、评分如何、时间安排等
我在 Python 中执行以下操作:
from googleplaces import GooglePlaces, types, lang
API_KEY = ''
google_places = GooglePlaces(API_KEY)
query_result = google_places.nearby_search(
location='Mumbai', keyword='Restaurants',
radius=1000, types=[types.TYPE_RESTAURANT])
if query_result.has_attributions:
print query_result.html_attributions
for place in query_result.places:
print place.name
print place.geo_location
print place.place_id
它 returns 我是这样的:
Subway
{u'lat': Decimal('19.1156005'), u'lng': Decimal('72.9090715')}
ChIJV2JWaObH5zsRt-FrEb8lrtM
Aroma's Cafe
{u'lat': Decimal('19.116867'), u'lng': Decimal('72.90982199999999')}
ChIJSWijB-bH5zsRVLE5ipsxvHU
Chili's
{u'lat': Decimal('19.1161942'), u'lng': Decimal('72.90909789999999')}
ChIJ4_2UcubH5zsRWMemt2WTsLc
Mainland China
{u'lat': Decimal('19.1154358'), u'lng': Decimal('72.90858159999999')}
ChIJ88dcaObH5zsRWLT4KyCLkI8
The Yellow Chilli
现在我想了解每家餐厅的详细信息(例如他们的评分、评论、时间安排)。如何使用 place_id
检索信息?
参考这个(向下滚动查看文档):
https://github.com/slimkrazy/python-google-places
它有你需要的所有电话。例如:
for place in query_result.places:
place.get_details()
print place.rating
将获得您的每个地点的评分。 github link 中几乎所有内容都适合您:)