Data acquisition using python googlemap api

Overview

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.

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

Structure of the acquired file

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

Data acquisition using python googlemap api
Data acquisition memo using Backlog API
Get Youtube data in Python using Youtube Data API
Creating Google Spreadsheet using Python / Google Data API
Data analysis using Python 0
Data cleaning using Python
[Python] Get all comments using Youtube Data API
Data analysis using python pandas
Get LEAD data using Marketo's REST API in Python
[Python] Get insight data using Google My Business API
Get Salesforce data using REST API
Get reviews with python googlemap api
[Python3] Google translate google translate without using api
Try using Pleasant's API (python / FastAPI)
Get Amazon data using Keep API # 1 Get data
Try using Python argparse's action API
[Python] I tried collecting data using the API of wikipedia
[Data science basics] Data acquisition from API
Run Ansible from Python using API
Play with YouTube Data API v3 using Google API Python Client
Collect product information and process data using Rakuten product search API [Python]
[Python] I tried to get various information using YouTube Data API!
Try using the Wunderlist API in Python
Try using the Kraken API in Python
Retrieving food data with Amazon API (Python)
Python: Reading JSON data from web API
I tried using YOUTUBE Data API V3
Tweet using the Twitter API in Python
Get Google Fit API data in Python
Python: Preprocessing in machine learning: Data acquisition
I tried using UnityCloudBuild API from Python
[Python] Various data processing using Numpy arrays
FX data collection using OANDA REST API
Awareness of using Aurora Severless Data API
Data analysis python
Start using Python
Scraping using Python
[python] Read data
Procedure to use TeamGant's WEB API (using python)
Try using the BitFlyer Ligntning API in Python
Python --bitfinex public API memo --ticker, trades acquisition
Get image URL using Flickr API in Python
Get stock price data with Quandl API [Python]
Let's judge emotions using Emotion API in Python
How to get article data using Qiita API
[Python3] Let's analyze data using machine learning! (Regression)
Recent ranking creation using Qiita API with Python
Manipulate objects using Blender 2.8's low-level Python API
Anonymous upload of images using Imgur API (using Python)
Python introductory study-output of sales data using tuples-
Stock price forecast using deep learning [Data acquisition]
Try using ChatWork API and Qiita API in Python
Try using the DropBox Core API in Python
Data acquisition from analytics API with Google API Client for python Part 2 Web application
Let's analyze Covid-19 (Corona) data using Python [For beginners]
Data analysis with python 2
Operate Redmine using Python Redmine
Upload JPG file using Google Drive API in Python
[Python] [Word] [python-docx] Simple analysis of diff data using python
Fibonacci sequence using Python
Python Data Visualization Libraries