DEV Community

voiddo
voiddo

Posted on Originally published at voidd0.github.io

Google Maps Scraper: how to get Places, Phones, Hours as JSON or CSV (Python, API, no code)

Scrape Google Maps business listings by search and place: name, category, address, coordinates, rating, review count, phone, website, opening hours, place ID and Maps link.

This tutorial shows what the Actor v0iddo/google-maps-scraper returns, how to run it on the Apify Store without code, and how to call it from Python and cURL.

What data you get

One row per result. Every row can be downloaded as JSON, CSV, Excel or HTML, or read through the API.

Field Label Type Example
name Name text Refinery High End Coffee
category Category text Coffee shop
address Address text Albrechtstraße 11B, 10117 Berlin, Germany
city City text Berlin
rating Rating number 4.6
reviewsCount Reviews number 1221
phone Phone text
website Website URL http://refinerycoffee.de/
latitude Latitude number 52.5213117
longitude Longitude number 13.3849173
placeId Place ID text ChIJ9UK3L8JRqEcRidYSi6cycYo
url Maps URL URL https://www.google.com/maps/place/?q=place_id:ChIJ9UK3L8JRqEcRidYSi...
searchQuery searchQuery text coffee shop in Berlin
position position number 1
categories categories list ["Coffee shop"]
street street text Albrechtstraße 11B
postalCode postalCode text 10117
countryCode countryCode text DE
neighborhood neighborhood text Mitte
openingHours openingHours list [{"day": "Monday", "hours": "8 AM-6 PM"}, {"day": "Tuesday", "hours...
featureId featureId text 0x47a851c22fb742f5:0x8a7132a78b12d689
cid cid text 9975810344776554121

Real rows from a run of the Actor (fields that name people are left out):

[
  {
    "searchQuery": "coffee shop in Berlin",
    "position": 1,
    "name": "Refinery High End Coffee",
    "category": "Coffee shop",
    "categories": [
      "Coffee shop"
    ],
    "address": "Albrechtstraße 11B, 10117 Berlin, Germany",
    "street": "Albrechtstraße 11B",
    "city": "Berlin",
    "postalCode": "10117",
    "countryCode": "DE",
    "neighborhood": "Mitte",
    "latitude": 52.5213117,
    "longitude": 13.3849173,
    "rating": 4.6,
    "reviewsCount": 1221,
    "website": "http://refinerycoffee.de/",
    "openingHours": [
      {
        "day": "Monday",
        "hours": "8 AM-6 PM"
      },
      {
        "day": "Tuesday",
        "hours": "8 AM-6 PM"
      },
      {
        "day": "Wednesday",
        "hours": "8 AM-6 PM"
      }
    ],
    "placeId": "ChIJ9UK3L8JRqEcRidYSi6cycYo",
    "featureId": "0x47a851c22fb742f5:0x8a7132a78b12d689",
    "cid": "9975810344776554121",
    "url": "https://www.google.com/maps/place/?q=place_id:ChIJ9UK3L8JRqEcRidYSi6cycYo"
  },
  {
    "searchQuery": "coffee shop in Berlin",
    "position": 2,
    "name": "LAP COFFEE",
    "category": "Coffee shop",
    "categories": [
      "Coffee shop"
    ],
    "address": "Rosenthaler Strasse 62, 10119 Berlin, Germany",
    "street": "Rosenthaler Strasse 62",
    "city": "Berlin",
    "postalCode": "10119",
    "countryCode": "DE",
    "neighborhood": "Mitte",
    "latitude": 52.5276603,
    "longitude": 13.4035268,
    "rating": 4.7,
    "reviewsCount": 851,
    "website": "http://www.lap.coffee/",
    "openingHours": [
      {
        "day": "Monday",
        "hours": "7:30 AM-6:30 PM"
      },
      {
        "day": "Tuesday",
        "hours": "7:30 AM-6:30 PM"
      },
      {
        "day": "Wednesday",
        "hours": "7:30 AM-6:30 PM"
      }
    ],
    "placeId": "ChIJZStJ7KFRqEcRzRngO3uVeHI",
    "featureId": "0x47a851a1ec492b65:0x7278957b3be019cd",
    "cid": "8248507074047121869",
    "url": "https://www.google.com/maps/place/?q=place_id:ChIJZStJ7KFRqEcRzRngO3uVeHI"
  }
]
Enter fullscreen mode Exit fullscreen mode

No code: run it on the Apify Store

  1. Open the Google Maps Scraper page on Apify.
  2. Fill in the input form. An example input is already filled in.
  3. Press Start, wait for the run to finish, and download the results as JSON, CSV or Excel from the Output tab.

The input that is pre-filled on the Actor page:

{
  "searchQueries": [
    "coffee shop"
  ],
  "location": "Berlin",
  "language": "en",
  "maxItems": 20
}
Enter fullscreen mode Exit fullscreen mode

Python (apify-client)

Get your API token in Apify Console under Settings, then Integrations. The Actor id is v0iddo/google-maps-scraper.

from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run_input = {'searchQueries': ['coffee shop'],
 'location': 'Berlin',
 'language': 'en',
 'maxItems': 20}

run = client.actor("v0iddo/google-maps-scraper").call(run_input=run_input)
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
Enter fullscreen mode Exit fullscreen mode

cURL

curl -X POST "https://api.apify.com/v2/acts/v0iddo~google-maps-scraper/run-sync-get-dataset-items" \
  -H "Authorization: Bearer YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"searchQueries": ["coffee shop"], "location": "Berlin", "language": "en", "maxItems": 20}'
Enter fullscreen mode Exit fullscreen mode

Good to know

  • Reads the public Google Maps search pages the way a visitor's browser does, with no login and no Google account. robots.txt of www.google.com allows these pages and the actor obeys it.
  • Google lists about 100 to 200 places for one search; for more, add queries or split by area ('dentist in Camden', 'dentist in Soho').
  • Phone and website are what the listing shows publicly for the business; many listings show no phone or website and have null there. No reviews or reviewer names are collected.
  • If Google shows a consent page, a CAPTCHA or an 'unusual traffic' page, the run stops and says so; the actor does not try to get around it. Run it again later.

Price

$1.50 per 1,000 results. You pay per result row. There is no separate charge per run. Higher Apify plans pay less per result, down to $1.05 per 1,000.

FAQ

What data does the Google Maps Scraper return?

Each result is one row in an Apify dataset. Fields include name, category, address, city, rating, reviewsCount, phone, website, and more. The table above shows every field with an example value.

Can I use it without writing code?

Yes. Open the Actor page on Apify, fill in the input form (an example is already filled in), press Start, and download the results as JSON, CSV, Excel or HTML. You can also schedule runs there.

How much does it cost?

$1.50 per 1,000 results. You pay per result row. There is no separate charge per run. Higher Apify plans pay less per result, down to $1.05 per 1,000. A new Apify account gets $5 of platform credit every month.

Links

Top comments (0)