Created
May 30, 2020 16:21
-
-
Save ChicagoDev/3babd954b5ace8a12053e71b3a6367e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import googlemaps | |
import json | |
from pprint import pprint | |
import time | |
## Import API Key | |
with open('config.json') as config_file: | |
config_data = json.load(config_file) | |
## Establish API Connection | |
gmaps = googlemaps.Client(key=config_data['maps_api_key']) | |
## Find places | |
barber_shops = gmaps.places('barber shop', radius=3218) | |
#Extract Next Page Token | |
npt = barber_shops["next_page_token"] | |
#For Usability | |
print(f'The first business returned is {barber_shops["results"][0]["name"]}') | |
print(f'\t The placed id is {barber_shops["results"][0]["id"]}') | |
print(f'\n\t\tThe next_page_token is {npt}') | |
#Request the next page || Raises googlemaps.exceptions.ApiError: INVALID_REQUEST | |
next_page_barber_shops = gmaps.places('barber shop', radius=3218, page_token=npt) | |
pprint(next_page_barber_shops) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment