DEV Community

Cover image for How to scrape Google Maps in Python
Vlad
Vlad

Posted on

How to scrape Google Maps in Python

Creating the scraper from scratch

Developing your own Google Maps scraping tool might be a big challenge in case you don't have a few years of experience behind you. You will need to be prepared for plenty of challenges from Google - IP protection (proxies), cookies & sessions, browser emulation, site updates, etc.

More quick and stable way

Fortunately, there are some good 3-rd party tools that you can easily integrate with your code and start scraping Google just within 5 minutes.

Getting started

Installation (Python 3+)

pip install google-services-api
Enter fullscreen mode Exit fullscreen mode

Usage

from outscraper import ApiClient

api_cliet = ApiClient(api_key='SECRET_API_KEY_FROM_OUTSCRAPER')
response = api_cliet.google_maps_search('restaurants brooklyn usa', language='en', region='US', limit=100)
Enter fullscreen mode Exit fullscreen mode

Response

{
  'id': '3f6f8bd0-4073-4ca3-b92f-4caff9cb0456',
  'status': 'Success',
  'data': [
    {
      'name': 'The Loft Steakhouse',
      'full_address': '1306 40th St, Brooklyn, NY 11218',
      'borough': 'Borough Park',
      'street': '1306 40th St',
      'city': 'Brooklyn',
      'postal_code': '11218',
      'country_code': 'US',
      'country': 'United States of America',
      'us_state': 'New York',
      'state': 'New York',
      'plus_code': None,
      'latitude': 40.639734499999996,
      'longitude': -73.9868193,
      'time_zone': 'America/New_York',
      'site': 'http://www.theloftsteakhouse.com/',
      'phone': '+1 718-475-5600',
      'type': 'Steak house',
      'subtypes': 'Steak house, Fine dining restaurant, Kosher restaurant, Delivery Restaurant, Takeout Restaurant, Restaurant',
      'posts': None,
      'rating': 4.9,
      'reviews': 1638,
      'photos_count': 1054,
      'google_id': '0x89c25ad4507a6e2f:0x135c0e38302054ac',
      'place_id': 'ChIJL256UNRawokRrFQgMDgOXBM',
      ...
    }
   ...
  ]
}
Enter fullscreen mode Exit fullscreen mode

Python package page

API docs

Top comments (0)