0% found this document useful (0 votes)
24 views1 page

Geoass - Jupyter Notebook

The document discusses searching for religious sites using the Google Places API. It provides code to make a request to the API with a location and keyword, handle any errors, and save the JSON response to a file.

Uploaded by

Prince M Nyathi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

Geoass - Jupyter Notebook

The document discusses searching for religious sites using the Google Places API. It provides code to make a request to the API with a location and keyword, handle any errors, and save the JSON response to a file.

Uploaded by

Prince M Nyathi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

UPDATE Read the migration plan to Notebook 7 to learn about the new features and the actions to take

ke if you are using extensions - Please note that updating to Notebook 7 might break some of your extensions. Don't show anymore

geoass Last Checkpoint: 12 minutes ago (autosaved) Logout

File Edit View Insert Cell Kernel Widgets Help Trusted Python 3 (ipykernel) 

        Run    Code 

In [ ]: import requests
import json
import os

####search for Religious sites using gooogle


def search_places(location, keyword):
try:
# Retrieve the API key from an environment variable
key=API_KEY = "AIzaSyCEirX0VeElR8KF5uXLRBbreQ2wSw5GEFE"

# Check if the API key is available


if key is None:
raise ValueError("Google Maps API key is not set. Please set the API key in your environment variables."

# Set up the API endpoint


url = f"https://maps.googleapis.com/maps/api/place/textsearch/json?query={keyword}+in+{location}&key={key}"

# Send the request to the API and get the response


response = requests.get(url)
response.raise_for_status() # Raise an exception for HTTP errors

# Parse the JSON response


data = response.json()

# Save the JSON response to a file


with open('/home/ace/places.json', "w") as json_file:

json.dump(data, json_file)

return data

except Exception as e:
print(f"An error occurred: {e}")
return None

# Example usage:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy