【发布时间】:2016-03-20 19:56:46
【问题描述】:
我正在使用带有 Python 的 Google Places API 来构建一个用于食物的集体智慧应用程序。例如附近有哪些餐馆,他们的评分是多少,他们的时间是什么等。
我在 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
它返回给我的是这样的:
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如何获取信息?
【问题讨论】:
-
尝试拨打
place.get_details(),然后拨打place.details。它是一个字典对象。 -
@Kris 但
place.details只返回有关 1 家餐厅的信息。我的query_result中有 20 个