I am using Google Places API for searching all the banks in my city, Karachi. There are thousands of banks in Karachi but my Python script is returning the results in very few records (10 to 15).

from googleplaces import GooglePlaces, types, lang
import pandas as pd
import json

API_KEY = 'AIzaSyCWKGmHNiCaO9mM5mMmpsulXBmRI3LDse4'

google_places = GooglePlaces(API_KEY)

df = pd.DataFrame()

    query_result = google_places.nearby_search(
    location='karachi', keyword='banks'
    radius=500, types=[types.TYPE_BANK])

if query_result.has_attributions:

for place in query_result.places:

    # df = json.loads(query_result.places)
    # df.to_csv('Places.csv', header=False, encoding='utf-8')

except Exception as ex:
with open('log.txt', 'a') as logfile:
    i = 0
    logfile.write(str(i) + "Error: " + str(ex) + '\n')
    i += 1
  • 3
    Scraping data is a violation of the terms of service. – Vince Mar 31 '18 at 13:33
  • Not scraping but want to get the correct response from the API. – Kamran Tariq Apr 2 '18 at 5:45

Maybe all the banks have not been mapped in google maps or google is limiting the results, scraping is not allowed with google maps. Instead of Google Maps, you can use OpenStreetmap which is open data and you can download your required data without having to scrape.

  • No, there are thousands of points available for the banks but the Places API is not returning the correct response. Although, its legal to scrap data from its API. – Kamran Tariq Apr 2 '18 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.