如何从Google Places API中的位置ID中获取位置详细信息

Nei*_*eil 5 python google-places-api

我正在将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  
Run Code Online (Sandbox Code Playgroud)

它返回我这样的东西:

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
Run Code Online (Sandbox Code Playgroud)

现在,我想了解每家餐厅的详细信息(例如其评分,评论,时间安排)。如何使用检索信息place_id

Kri*_*ris 3

请参阅此(向下滚动查看文档):

https://github.com/slimkrazy/python-google-places

它有您需要的所有电话。例如:

for place in query_result.places:
    place.get_details()
    print place.rating
Run Code Online (Sandbox Code Playgroud)

将获得您每个地点的评分。几乎所有内容都在 github 链接中为您提供:)