2016-08-24 2 views
-2

Я пытаюсь захватить детали Starbucks магазинов в Ковентри, как имя, местонахождение, адрес и URL Google Maps, но я не могу показаться, чтобы обернуть вокруг головы графику (часы работы)Python Google Адресов 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

попытка поиска Google Places API текста найти place_id

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

Это апи вернет вам JSon response.Parse 'place_id' из этого места, которое "ChIJV0Xu7bdLd0gRyYvYroskQ0k"

использовать этот " place_id»в Google место детали апи, чтобы получить часы

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

это вернет ответ json, который включает в себя часы работы

+0

Ι' написал мою собственную функцию python, которая входит в JSON, захватывает часы работы и печатает ее соответственно День –

+0

Спасибо за помощь! –

+0

@GeorgeZachariadis welcome –

Смежные вопросы