PlaceSummary / app.py
antfraia's picture
Update app.py
7aa96dc
raw
history blame
1.29 kB
import streamlit as st
from apify_client import ApifyClient
# Initialize the ApifyClient with your API token
client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
# Streamlit UI
st.title("Places Information")
website_name = st.text_input("Enter the type of place (e.g., restaurant, cafe):", "restaurant")
location = st.text_input("Enter the location:", "New York, USA")
button = st.button("Fetch Information")
def fetch_places_from_google_maps(website_name, location):
try:
run_input = {
"searchStringsArray": [website_name],
"locationQuery": location,
"maxCrawledPlacesPerSearch": 1, # Fetching only one record for simplicity
# Other input parameters can be added as per your requirements
}
# Update the actor call
run = client.actor("compass~crawler-google-places").call(run_input=run_input)
items = list(client.dataset(run["defaultDatasetId"]).iterate_items())
if items:
return items[0]
except Exception as e:
st.write(f"Error: {str(e)}")
return None
if button:
place_data = fetch_places_from_google_maps(website_name, location)
if place_data:
st.write(place_data)
else:
st.write("No data found!")