41

I am trying to find all "restaurants" or "insurance agencies" for example, in a city or country. Okay, maybe a country is too broad but mainly large cities.

I am using the Google Places API and python but I see that you can only use a "radius" parameter or "rankby=distance". The problem is that, according to the docs, I believe that each query can only return 20 results on 3 pages, or 60 results (correct me if I am wrong). So if I wanted to find all the restaurants in New York for example, I would have to start at the center or something and set "rankby=distance" so that it would give me the 60 closest results within a set radius. But then I don't know what my next query would be...

Any ideas how to go about doing this?

Marcus Johnson
  • 2,505
  • 6
  • 22
  • 27

8 Answers8

36

Unfortunately you can't get more than 60 results from the Google Places API; at least not without breaking the terms of service:

Unless you have received prior written authorization from Google (or, as applicable, from the provider of particular Content), you must not: (d) use the Products in a manner that gives you or any other person access to mass downloads or bulk feeds of any Content, including but not limited to numerical latitude or longitude coordinates, imagery, and visible map data

Furthermore, as you can read here:

It's in large part a licensing issue. But it's also because the goal of the Places API is not to facilitate scraping or aggregation of Google Places data in the way you describe. Any application that does so is almost certainly not compliant with the Google Maps or Google Maps API Terms of Service, and is likely to be blocked from using the API or other Google services at any time. The Places API is intended to allow apps to offer their users a way to discover of identify Places nearby. There is a practical limit to the number of search results that a user will scan through and consider. I don't believe it's necessary to offer users 200 results, and I suspect that doing so would only serve to increase development of applications that scrape Google Places data, without adding significant benefit or utility to the types of apps the API is intended to serve, and that we wish to encourage.

As a further reference, have also a look at this answer.

Community
  • 1
  • 1
4

Use Radar Search. Check the documentation here.

You can get 200 results in one go but it will take 5 reqests from your quota. The results have less details as compared to nearby search but you can always get that by using place details search.

Hope this helps.

Notice: Radar search is deprecated as of June 30, 2018. After that time, this feature will no longer be available.

ewizard
  • 2,801
  • 4
  • 52
  • 110
Rahul Sainani
  • 3,437
  • 1
  • 34
  • 48
4

I made such a tool a while ago https://github.com/Pithikos/Geoexplorer. You can see here how it looks like.

I even have a working example with Google Places that you can use if you have an API key.

  1. git clone https://github.com/Pithikos/Geoexplorer.git
  2. Add your API key in the file examples/google_radar_search.py
  3. python3 examples/google_radar_search.py
  4. Open GUI/index.html in a browser

This will look for groceries named "ICA" in a big area in Sweden. You can configure the area being scanned at config.py and your search queries in google_radar_search.py.

This should run fine on any Ubuntu after 13.10. If you use Windows or an earlier version read here (the Install dependencies section).

You can also add any other service you like by using the API. Keep in mind to not violate Google's or any other company's policy when using it. I made this solely to test which service would give me the best results before deciding which of them to use.

Pithikos
  • 18,827
  • 15
  • 113
  • 136
  • Will this be suitable for getting all businesses of all types within a certain country? Radar Search no longer exists, so we're left with Nearby Searches. However, that only returns max 60 results, so if you retrieve 60 results for a particular radius, your algo needs to then drill in to a smaller radiuses successively, until you're retrieving results <60. Does it do that? Do you also deal with the overlapping circles duplicate problem? – poshest Oct 30 '20 at 11:10
2

Unfortunately Google does not want people to be able to do this, and so they design their API to prevent people from doing things like this. However there are alternatives. If you want to do this with API access Factual is the leader; they have 102 million entries in 50 countries.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
2

I created crawler on top of Google Map search, you can use it for this use case. You can check the crawler here.

drobnikj
  • 448
  • 2
  • 7
1

Use Page token in URL and you can get all results.

Requirements:

  • Need place API key.
  • Install requests library.

you can try below code:

import requests
import json

final_data = []

location='24.4165267,75.833981'
radius='2000'
types='restaurant'
url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=%s&radius=%s&types=%s&key=api key" % (location,radius,types)

while True:

    response = requests.request("POST", URL)
    response = json.loads(response.text)
    results = response['results']

    for result in results:
       final_data.append(data)

    if 'next_page_token' not in response:
        break
    else:
        next_page_token = response['next_page_token']

    next_page_token = '&pagetoken=%s' % str(next_page_token)
    url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=%s&radius=%s&types=%s&key=api key%s" % (location,radius,types,next_page_token)

print(final_data)
Ankit Patidar
  • 467
  • 5
  • 6
0

from my understanding .. we would recommend use cross api reference in my scenario in would use nesting of async WCF call to area divided by limited call laid down by google

Rizwan Patel
  • 538
  • 2
  • 9
  • 27
0

You could use a third party solution like SerpApi. It's a paid API with a free trial. We handle proxies, solve captchas, and parse all the rich structured data for you.

We provide the API for scraping full Google Places result as well as Google Maps results.

Milos Djurdjevic
  • 364
  • 1
  • 11