CoderCastrov logo
CoderCastrov
Отзывы Google

Парсинг отзывов Google Maps на Python

Парсинг отзывов Google Maps на Python
просмотров
3 мин чтение
#Отзывы Google
Google Maps отзывы

Официальное API Google Places ограничивает количество отзывов, которые мы можем получить, используя его.

"predictions" содержит массив мест с информацией о месте. Places API возвращает до 5 результатов.

Поэтому разработчики и специалисты по обработке данных используют сторонние сервисы, чтобы преодолеть это ограничение и спарсить все отзывы с Google.

Начало работы

Мы будем использовать python 3+ и Outscraper SDK: pip install google-services-api

Извлечение 100 отзывов о Flatiron Building:

from outscraper import ApiClient

api_cliet = ApiClient(api_key='API-KEY')
response = api_cliet.google_maps_business_reviews(
    ' Flatiron Building , NY, USA', limit=100, language='en')  

API-KEY — ключ API со страницы Профиля Outscraper.

Ответ:

{
  'name': 'Flatiron Building',
  'full_address': '175 5th Ave, New York, NY 10010',
  'borough': 'Manhattan',
  'street': '175 5th Ave',
  'city': 'New York',
  'postal_code': '10010',
  'country_code': 'US',
  'country': 'United States of America',
  'us_state': 'New York',
  'state': 'New York',
  'plus_code': None,
  'latitude': 40.741060499999996,
  'longitude': -73.9896986,
  'time_zone': 'America/New_York',
  'site': None,
  'phone': None,
  'type': 'Building',
  'subtypes': 'Building, Historical place, Tourist attraction',
  'posts': None,
  'rating': 4.6,
  'reviews': 9535,
  ...
  'reviews_data': [
    {
      'google_id': '0x89c259a3f71c1f67:0xde2a6125ed704926',
      'autor_link': '[https://www.google.com/maps/contrib/108165337885780226981?hl=en-US'](https://www.google.com/maps/contrib/108165337885780226981?hl=en-US%27),
      'autor_name': 'F vT',
      'autor_id': '108165337885780226981',
      'review_text': 'Loved seeing it! Incredible craftsmanship especially for the time back then. Overall great experience.',
      'review_img_url': '[https://lh5.googleusercontent.com/p/AF1QipNzKeuVkZjXs7i__Q9BbHKAIlwlLzGTlaebyQj5'](https://lh5.googleusercontent.com/p/AF1QipNzKeuVkZjXs7i__Q9BbHKAIlwlLzGTlaebyQj5'),
      'owner_answer': None,
      'owner_answer_timestamp': None,
      'owner_answer_timestamp_datetime_utc': None,
      'review_link': '[https://www.google.com/maps/reviews/data=!4m5!14m4!1m3!1m2!1s108165337885780226981!2s0x0:0xde2a6125ed704926?hl=en-US'](https://www.google.com/maps/reviews/data=!4m5!14m4!1m3!1m2!1s108165337885780226981!2s0x0:0xde2a6125ed704926?hl=en-US%27),
      'review_rating': 5,
      'review_timestamp': 1609146487,
      'review_datetime_utc': '12/28/2020 09:08:07',
      'review_likes': 0
    },
    {
      'google_id': '0x89c259a3f71c1f67:0xde2a6125ed704926',
      'autor_link': '[https://www.google.com/maps/contrib/104605213761142288909?hl=en-US'](https://www.google.com/maps/contrib/104605213761142288909?hl=en-US%27),
      'autor_name': 'Isaac Green',
      'autor_id': '104605213761142288909',
      'review_text': 'This beautiful structure was the tallest building in the world for a brief time period. It was among the architectural "tests" to determine if internal steel skeletons could support (in practice) "high rise" buildings. It is not far from our Greenwich Village neighborhood and we never cease to marvel at its decorative facades when we pass by on our way to Madison Square Park.',
      'review_img_url': None,
      'owner_answer': None,
      'owner_answer_timestamp': None,
      'owner_answer_timestamp_datetime_utc': None,
      'review_link': '[https://www.google.com/maps/reviews/data=!4m5!14m4!1m3!1m2!1s104605213761142288909!2s0x0:0xde2a6125ed704926?hl=en-US'](https://www.google.com/maps/reviews/data=!4m5!14m4!1m3!1m2!1s104605213761142288909!2s0x0:0xde2a6125ed704926?hl=en-US%27),
      'review_rating': 5,
      'review_timestamp': 1608547986,
      'review_datetime_utc': '12/21/2020 10:53:06',
      'review_likes': 0
    },
    {
      'google_id': '0x89c259a3f71c1f67:0xde2a6125ed704926',
      'autor_link': '[https://www.google.com/maps/contrib/118280614781220750824?hl=en-US'](https://www.google.com/maps/contrib/118280614781220750824?hl=en-US%27),
      'autor_name': 'Lionel Grant',
      'autor_id': '118280614781220750824',
      'review_text': 'Incredibly beautiful building you should definitely look at it and take a few photos near it, its unusual shape of the building attracts attention',
      'review_img_url': None,
      'owner_answer': None,
      'owner_answer_timestamp': None,
      'owner_answer_timestamp_datetime_utc': None,
      'review_link': '[https://www.google.com/maps/reviews/data=!4m5!14m4!1m3!1m2!1s118280614781220750824!2s0x0:0xde2a6125ed704926?hl=en-US'](https://www.google.com/maps/reviews/data=!4m5!14m4!1m3!1m2!1s118280614781220750824!2s0x0:0xde2a6125ed704926?hl=en-US%27),
      'review_rating': 5,
      'review_timestamp': 1609158664,
      'review_datetime_utc': '12/28/2020 12:31:04',
      'review_likes': 0
    },
    {
      'google_id': '0x89c259a3f71c1f67:0xde2a6125ed704926',
      'autor_link': '[https://www.google.com/maps/contrib/101363049415519675838?hl=en-US'](https://www.google.com/maps/contrib/101363049415519675838?hl=en-US%27),
      'autor_name': 'Burak Eseroglu',
      'autor_id': '101363049415519675838',
      'review_text': 'The distinctive triangular shape of the Flatiron Building, built in 1902, allowed it to fill the wedge-shaped property located at the intersection of Fifth Avenue and Broadway. The building was intended to serve as offices. At 22 stories and 307 feet, the Flatiron was never the city’s tallest building, but always one of its most dramatic-looking, and its popularity with photographers and artists has made it an enduring symbol of New York for more than a century.',
      'review_img_url': '[https://lh5.googleusercontent.com/p/AF1QipPNNO2s9Phb90fQpeuqo-s96wbyyaj5sXv34-aL'](https://lh5.googleusercontent.com/p/AF1QipPNNO2s9Phb90fQpeuqo-s96wbyyaj5sXv34-aL'),
      'owner_answer': None,
      'owner_answer_timestamp': None,
      'owner_answer_timestamp_datetime_utc': None,
      'review_link': '[https://www.google.com/maps/reviews/data=!4m5!14m4!1m3!1m2!1s101363049415519675838!2s0x0:0xde2a6125ed704926?hl=en-US'](https://www.google.com/maps/reviews/data=!4m5!14m4!1m3!1m2!1s101363049415519675838!2s0x0:0xde2a6125ed704926?hl=en-US%27),
      'review_rating': 5,
      'review_timestamp': 1598338191,
      'review_datetime_utc': '08/25/2020 06:49:51',
      'review_likes': 9
    },
    {
      'google_id': '0x89c259a3f71c1f67:0xde2a6125ed704926',
      'autor_link': '[https://www.google.com/maps/contrib/104062599101003904508?hl=en-US'](https://www.google.com/maps/contrib/104062599101003904508?hl=en-US%27),
      'autor_name': 'Tofe Evans',
      'autor_id': '104062599101003904508',
      'review_text': 'Amazing piece of architecture. Pics were taken pre-COVID',
      'review_img_url': '[https://lh5.googleusercontent.com/p/AF1QipNwFHfPauT2WXL-XiyyqlLtznfvmNDZYs7MvUln'](https://lh5.googleusercontent.com/p/AF1QipNwFHfPauT2WXL-XiyyqlLtznfvmNDZYs7MvUln'),
      'owner_answer': None,
      'owner_answer_timestamp': None,
      'owner_answer_timestamp_datetime_utc': None,
      'review_link': '[https://www.google.com/maps/reviews/data=!4m5!14m4!1m3!1m2!1s104062599101003904508!2s0x0:0xde2a6125ed704926?hl=en-US'](https://www.google.com/maps/reviews/data=!4m5!14m4!1m3!1m2!1s104062599101003904508!2s0x0:0xde2a6125ed704926?hl=en-US%27),
      'review_rating': 5,
      'review_timestamp': 1606388920,
      'review_datetime_utc': '11/26/2020 11:08:40',
      'review_likes': 3
    },
    {
      'google_id': '0x89c259a3f71c1f67:0xde2a6125ed704926',
      'autor_link': '[https://www.google.com/maps/contrib/116751820397872758328?hl=en-US'](https://www.google.com/maps/contrib/116751820397872758328?hl=en-US%27),
      'autor_name': 'Abhimanyu Dawar',
      'autor_id': '116751820397872758328',
      'review_text': 'Amazing architecture and vibe around the Flatiron building. South of Manhattan downtown. This 22 story building is a delight for photographers. One can spend hours capturing this building. There are cafe around it that one can enjoy.\n\nThis is one of the most iconic structures in Manhattan NYC',
      'review_img_url': '[https://lh5.googleusercontent.com/p/AF1QipNG9hHFWlBpnLErK6BRZB82DH-cy8XwGHe5MFeX'](https://lh5.googleusercontent.com/p/AF1QipNG9hHFWlBpnLErK6BRZB82DH-cy8XwGHe5MFeX'),
      'owner_answer': None,
      'owner_answer_timestamp': None,
      'owner_answer_timestamp_datetime_utc': None,
      'review_link': '[https://www.google.com/maps/reviews/data=!4m5!14m4!1m3!1m2!1s116751820397872758328!2s0x0:0xde2a6125ed704926?hl=en-US'](https://www.google.com/maps/reviews/data=!4m5!14m4!1m3!1m2!1s116751820397872758328!2s0x0:0xde2a6125ed704926?hl=en-US%27),
      'review_rating': 5,
      'review_timestamp': 1588506619,
      'review_datetime_utc': '05/03/2020 11:50:19',
      'review_likes': 6
    },
    ...
  ]
}

Страница пакета Python

Документация по API