It is a memorandum of data acquisition using google api with python. Note that the structure of the acquired data was difficult to understand.
From api key acquisition to scraping was done according to the reference site.
I tried to get data using Google Places API in Python How to display data acquired using Google Places API in Python Try to get a "restaurant" near the company with Google Places API google api reference
The output of the data is as follows.
{'html_attributions': [],
'next_page_token': 'CqQCEwEAAND0XppPuvvrCXmUQzMNptKvNU7uZqS-Rq2gRv0w9yD2ZsQDh-G1qr-hn81mrh-SWe_DG6jU2tyhjw-45yKrcPzXuOgs64avoooWYhoV68bXFGB75bH7StQLeqGzIuX30zQL5WY3MPX2Jke5aDrH45Tp28hL8LpK-vohhX3fobc9mgRJSY8HC_9_qiFOLqeYRDEdPu_dlHkqusMuALzXLYrn00-Y_hh8HdXRuAZGOyfgfn9ebP-DNdHvUZSykKfFFAfuUfuJHMv52Ilyhc4DJ4HHVLn7Kdn_5AXjyOl7JLSwHhiwXXR4FIlMziEo4IuE--fezO0oDiWJQKTHFnpuw5fAf6sEZTad1A3Hi7gRzuSHsCCeCRdwDU7Afd4bsnv7tRIQUjmDjaLVulM6S7C0y2hu_xoULb-LLjjS2Hk356DGIg_pMyFMotY',
'results': [{'geometry': {'location': {'lat': 35.6803997, 'lng': 139.7690174},
'viewport': {'northeast': {'lat': 35.8174453,
'lng': 139.9188743},
'southwest': {'lat': 35.519042,
'lng': 139.5628611}}},
'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/geocode-71.png',
'name': 'Tokyo',
'photos': [{'height': 3394,
'html_attributions': ['<a '
'href="https://maps.google.com/maps/contrib/117659812595877252927">Yujin '
'Flin</a>'],
'photo_reference': 'CmRaAAAAqhq5iHusvG2XuIy2ytbybDLzf1Ral74YI8qLoCBU2Gr4JE1p2pSRhHs6KEF1qtZ8m2RLNW_2SqLXB6pN8anGfIcKnSNARD0Vb4xY4oOcHD2bMfTv2vtrBxO61oA3LJ9NEhDe0VxlVJns646OdP0_nxW1GhRFjIHJ4aEwUUnbrWMYpbAZcfPMpQ',
'width': 5000}],
'place_id': 'ChIJXSModoWLGGARILWiCfeu2M0',
'reference': 'ChIJXSModoWLGGARILWiCfeu2M0',
'scope': 'GOOGLE',
'types': ['colloquial_area', 'locality', 'political'],
'vicinity': 'Tokyo'},
{'business_status': 'OPERATIONAL',
'geometry': {'location': {'lat': 35.65861110000001,
'lng': 139.6997222},
'viewport': {'northeast': {'lat': 35.65996008029151,
'lng': 139.7010711802915},
'southwest': {'lat': 35.65726211970851,
'lng': 139.6983732197085}}},
'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',
'name': 'Shibuya Excel Hotel Tokyu',
'opening_hours': {'open_now': True},
'photos': [{'height': 1701,
'html_attributions': ['<a '
'href="https://maps.google.com/maps/contrib/101297695086602663090">Shibuya Excel Hotel Tokyu</a>'],
'photo_reference': 'CmRaAAAAzCl7D_cLECSouuCGIWrTZxi9PiZAY2SOD7VkIJaehZagYQG8IvQjCHIhhIPFXm8C1NBRSwVOj2isqVY1Y8D0J-QEXxtPg8hAUTOMIDQ2rw2H-TJQj1sYNSzAStGOzmuBEhATXspuQcWTZYdPCG3YPb39GhRMadylKeVy4oSpN4RnxPgPi-9lrQ',
'width': 2268}],
'place_id': 'ChIJTzNfw1eLGGARagCmVhCOmP4',
'plus_code': {'compound_code': 'MM5X+CV Shibuya City, Tokyo, '
'Japan',
'global_code': '8Q7XMM5X+CV'},
'price_level': 2,
'rating': 4.1,
'reference': 'ChIJTzNfw1eLGGARagCmVhCOmP4',
'scope': 'GOOGLE',
'types': ['lodging',
'restaurant',
'food',
'point_of_interest',
'establishment'],
'user_ratings_total': 1853,
'vicinity': '1 Chome-12-2 Dogenzaka, Shibuya City'},
{'business_status': 'OPERATIONAL',
'geometry': {'location': {'lat': 35.656286, 'lng': 139.7015866},
'viewport': {'northeast': {'lat': 35.6576349802915,
'lng': 139.7029355802915},
'southwest': {'lat': 35.65493701970851,
'lng': 139.7002376197085}}},
'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',
'name': 'Shibuya Granbell Hotel',
'opening_hours': {'open_now': True},
'photos': [{'height': 3745,
'html_attributions': ['<a '
'href="https://maps.google.com/maps/contrib/102750292639177188533">Sakurai '
'Daisuke</a>'],
'photo_reference': 'CmRaAAAAqgA3yyukqjzUrJynEUc0MiSicVaas7mSYJtDxIYbFxjnPPSDxjEdOEcLRxGMY_zTeKH7RF_cQbsLXE1fWg6zwpG8wPkuRcyu5u6GeZyP1irGJ7hfydeLGOoQJEkah1hzEhBTXJyTR0gVkYuGwOMGr6BuGhTSiw-guLPEDDzOJWd9hXrbR9Jc3Q',
'width': 3000}],
'place_id': 'ChIJkwh-41mLGGARZASpROEIZrk',
'plus_code': {'compound_code': 'MP42+GJ Shibuya City, Tokyo, '
'Japan',
'global_code': '8Q7XMP42+GJ'},
'rating': 4,
'reference': 'ChIJkwh-41mLGGARZASpROEIZrk',
'scope': 'GOOGLE',
'types': ['lodging', 'point_of_interest', 'establishment'],
'user_ratings_total': 533,
'vicinity': '15-17 Sakuragaokacho, Shibuya City'},
It is a nested dictionary, and the keys at the top level are composed of the following four. html_attributions next_page_token results status Of these, the main data is in'results'. Some keys below results also have a nested structure.
The rating is displayed as'rate'. How do you get a list of review comments ...
Recommended Posts