Spaces:
Sleeping
Sleeping
File size: 1,291 Bytes
3e996d0 ba1946b 3e996d0 7aa96dc 3e996d0 7aa96dc 3e996d0 7aa96dc 3e996d0 7aa96dc 3e996d0 7aa96dc ba1946b 7aa96dc ba1946b 7aa96dc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
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!") |