2016-08-24 60 views
-2

我想捕捉的星巴克商店的细节在考文垂,如姓名,位置,地址和谷歌地图的网址,但我似乎无法环绕时间表我的头(营业时间)Python的谷歌Places API的

print place.details 

会给你一个JSON格式的所有细节,我怎么只保留营业时间

Starbucks Coffee 
This is the address of the place : Gulson Road Coventry University, Coventry CV1 2JH, UK 
The google map page : https://maps.google.com/?cid=5279103370560834505 
The type of place : [u'cafe', u'food', u'store', u'point_of_interest', u'establishment'] 
{u'website': u'http://www.starbucks.co.uk/store/91356/gb/coventry-university-ecb/gulson-road-ecb-engineering-computing-building', u'utc_offset': 60, u'name': u'Starbucks Coffee', u'reference': u'CnRjAAAADvWg02OACGcjnA6lDYaiHaLuZDZkFnL3lGuw_QOw0i4fmmgcaUXXyROMIKW3eZR1tvorm-T6fAG0b815POJV7mSg4MnISitEn_SKGcs5hq5I2DY2CyAiwAFFjDsJkEWrj6NFEjnaF916KuQ-JXfzghIQdSyG6bHTdaMvn-ZZFXLR5hoUFsXDJ9gx-l0Ys5D6BG9IQV1emGU', u'price_level': 2, u'geometry': {u'location': {u'lat': Decimal('52.4055608'), u'lng': Decimal('-1.4997924')}, u'viewport': {u'northeast': {u'lat': Decimal('52.40569205'), u'lng': Decimal('-1.49939775')}, u'southwest': {u'lat': Decimal('52.40551705000001'), u'lng': Decimal('-1.49992395')}}}, u'adr_address': u'Gulson Road Coventry University, <span class="locality">Coventry</span> <span class="postal-code">CV1 2JH</span>, <span class="country-name">UK</span>', u'place_id': u'ChIJV0Xu7bdLd0gRyYvYroskQ0k', u'international_phone_number': u'+44 24 7622 5719', u'vicinity': u'Coventry, Gulson Road Coventry University, Coventry', u'reviews': [{u'rating': 4, u'aspects': [{u'rating': 2, u'type': u'overall'}], u'profile_photo_url': u'//lh5.googleusercontent.com/-Ksa5MB3V150/AAAAAAAAAAI/AAAAAAAAN1g/Oc9XyOBsRAI/photo.jpg', u'language': u'en', u'text': u"It's Starbucks in EC building, save you walking in town for a hot beverage", u'author_name': u'Dhruv Bhakta', u'author_url': u'https://plus.google.com/106741921003476599081', u'time': 1453209416}], u'formatted_phone_number': u'024 7622 5719', u'scope': u'GOOGLE', u'url': u'https://maps.google.com/?cid=5279103370560834505',---> I want just that u'opening_hours': {u'weekday_text': [u'Monday: 8:00 AM \u2013 6:30 PM', u'Tuesday: 8:00 AM \u2013 6:30 PM', u'Wednesday: 8:00 AM \u2013 6:30 PM', u'Thursday: 8:00 AM \u2013 6:30 PM', u'Friday: 8:00 AM \u2013 6:00 PM', u'Saturday: Closed', u'Sunday: Closed'], u'open_now': False, u'periods': [{u'close': {u'day': 1, u'time': u'1830'}, u'open': {u'day': 1, u'time': u'0800'}}, {u'close': {u'day': 2, u'time': u'1830'}, u'open': {u'day': 2, u'time': u'0800'}}, {u'close': {u'day': 3, u'time': u'1830'}, u'open': {u'day': 3, u'time': u'0800'}}, {u'close': {u'day': 4, u'time': u'1830'}, u'open': {u'day': 4, u'time': u'0800'}}, {u'close': {u'day': 5, u'time': u'1800'}, u'open': {u'day': 5, u'time': u'0800'}}]}, <---- until here u'address_components': [{u'long_name': u'Coventry', u'types': [u'locality', u'political'], u'short_name': u'Coventry'}, {u'long_name': u'Coventry', u'types': [u'postal_town'], u'short_name': u'Coventry'}, {u'long_name': u'West Midlands', u'types': [u'administrative_area_level_2', u'political'], u'short_name': u'West Midlands'}, {u'long_name': u'England', u'types': [u'administrative_area_level_1', u'political'], u'short_name': u'England'}, {u'long_name': u'United Kingdom', u'types': [u'country', u'political'], u'short_name': u'GB'}, {u'long_name': u'CV1 2JH', u'types': [u'postal_code'], u'short_name': u'CV1 2JH'}], u'formatted_address': u'Gulson Road Coventry University, Coventry CV1 2JH, UK', u'id': u'7fd44a38d5776818e51953ee7188f10d54b768cc', u'types': [u'cafe', u'food', u'store', u'point_of_interest', u'establishment'], u'icon': u'https://maps.gstatic.com/mapfiles/place_api/icons/cafe-71.png'} 

细节输出上面,但我只想要日程。

+0

尝试'place.details [u'opening_hours']' – spiv

回答

1

尝试谷歌的地方文本搜索API找到place_id

https://maps.googleapis.com/maps/api/place/textsearch/json?query=StarbucksCoffee,GulsonRoad,CoventryUniversity,CoventryCV12JH,UK&key=YOUR_API_KEY

这个API将返回这个地方,这是 “ChIJV0Xu7bdLd0gRyYvYroskQ0k”

使用这种'的JSON response.Parse 'place_id' place_id”在谷歌地点的详细信息API来获取营业时间

https://maps.googleapis.com/maps/api/place/details/json?ChIJV0Xu7bdLd0gRyYvYroskQ0k=&key=YOUR_API_KEY

这将返回一个包含开放时间的json响应

+0

我写了自己的自定义python函数进入JSON,获取开放时间并相应地打印它当天 –

+0

感谢您的帮助! –

+0

@GeorgeZachariadis欢迎 –

相关问题