-1
私は座標の場所idを取得するためにgoogles places apiを使用しようとしています。私はAPIをロードするとPYTHONがjsonを返すAPIを使用しています
、それは私に次のようになり混乱できます:ここで
{u'status': u'OK', u'html_attributions': [], u'results': [{u'name': u'San Francisco', u'reference': u'CmRbAAAAnnZ_G3vbVvFkLZ16Xs72Q_tCThBw8l-KRAfV-nkjJFhSct6iLCMjagLDx8fKzCe81qVelkHPCqlSo-0LghXfgrLgvHqfOL35HNBy18y2Ka6omKGFkNOmqkq1S6qI_zrBEhCogABq1AbcBQ4faNocEUr6GhQGVdTeVkvee1UlP0eNqoXphBAklg', u'geometry': {u'location': {u'lat': 37.7749295, u'lng': -122.4194155}, u'viewport': {u'northeast': {u'lat': 37.812, u'lng': -122.3482}, u'southwest': {u'lat': 37.70339999999999, u'lng': -122.527}}}, u'place_id': u'ChIJIQBpAG2ahYAR_6128GcTUEo', u'vicinity': u'San Francisco', u'photos': [{u'photo_reference': u'CoQBdwAAAMCSQa5APDsro3A01s2y_8ZJdlAfwEs8hDR-rY8qmDqpsI8lNeyAnA8ABqGdMCz7t4NDpqFEO4jyKzqrEjQfn8nX-KQrDui4Gpug9ZPFlC2tAE1mQpN-ZiqTQzi-RG1joYvP_D3x47k0IMuXg10n4omryejkNwSOIRu1lKH19ZHaEhDU41FXWZxOPntG9IiQFUaDGhR7vMx9AR77vnyYGxy5NkaqriIZgg', u'width': 3264, u'html_attributions': [u'<a href="https://maps.google.com/maps/contrib/117460775221769242461/photos">Jasmine Crooms</a>'], u'height': 1836}], u'scope': u'GOOGLE', u'id': u'1b9ea3c094d3ac23c9a3afa8cd4d8a41f05de50a', u'types': [u'locality', u'political'], u'icon': u'https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png'}, {u'name': u'Western Addition', u'reference': u'CmRbAAAAJczj_jM4I_aXrbmEGwb6wzdmvaf0OKjSMOgV9rXg-nyeYd-yE-jsHR-tUSl8pX0bykr-pF-boCGYt-SFQHHJYre7ohXL9JfyirKv58xuyBlYvewGsvmA8jGfpaVQKmaSEhB6JZF791kqmbSgT3xL3wEgGhQlewM9G3Tk4aLDv_IZVExxYU3EKg', u'geometry': {u'location': {u'lat': 37.7822112, u'lng': -122.4341781}, u'viewport': {u'northeast': {u'lat': 37.7903498, u'lng': -122.4210075}, u'southwest': {u'lat': 37.7690383, u'lng': -122.4476754}}}, u'place_id': u'ChIJORmAxLuAhYARJN5IphkMohE', u'vicinity': u'San Francisco', u'photos': [{u'photo_reference': u'CoQBdwAAAHZ2hI-5aQ_7YdcyvEGaNLE2P1WjCigqyq03V5PeSZkTzNEIf-Ft6OwTsdnuNbPBmDVRxTE_8KrQXdcsTr7_Z6fi5CX1WXkhRDnq58xNgl_VlvRRyAOT4aRGaWC0J6NUb9BW_1a6YuMuinqapQj3LO_esfJr2vm-E7MguPSSrdFrEhCxbibPaEYpkHZWUKAuC6j6GhQM6vPmaLMRZvXayFZ56J3p-7lFtw', u'width': 7192, u'html_attributions': [u'<a href="https://maps.google.com/maps/contrib/118017203244853378703/photos">Mohd Al-Alami</a>'], u'height': 4792}], u'scope': u'GOOGLE', u'id': u'59716f06d3d1b69830d34520b29ec95352234db1', u'types': [u'neighborhood', u'political'], u'icon': u'https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png'}]}
を私のコードです:
import urllib2, json
latitude = '37.773972'
longitude = '-122.431297'
key = 'mykey'
url = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=' + latitude + ',' + longitude + '&radius=1&key=' + key
json_obj = urllib2.urlopen(url)
data = json.load(json_obj)
print data["place_id"]
place_idというフィールドがありますが、私はしようとすると、エラーが返されます。
Traceback (most recent call last):
File "C:\Users\Damon\Desktop\Coding\Python\placeid.py", line 11, in <module>
print data["place_id"]
KeyError: 'place_id'
このplace_idを取得する方法はありますか?