Spaces:
Sleeping
Sleeping
import streamlit as st | |
from apify_client import ApifyClient | |
import requests | |
# API Keys | |
APIFY_KEY = 'apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp' | |
WEATHER_KEY = '91b23cab82ee530b2052c8757e343b0d' | |
# Set up clients | |
apify_client = ApifyClient(APIFY_KEY) | |
st.title("Comprehensive Place Summary App") | |
website_name = st.text_input("Enter website / company name:") | |
# 1. Website API Integration (if needed in the future) | |
def fetch_website_content(website_name): | |
run = apify_client.actor("mc9KJTQJg3zfQpANg/aYG0l9s7dbB7j3gbS").call(run_input={}) | |
items = [item for item in apify_client.dataset(run["defaultDatasetId"]).iterate_items()] | |
return items | |
# 2. Google Maps API Integration | |
def fetch_google_maps_info(website_name): | |
run_input = { | |
"searchStringsArray": [website_name], | |
"locationQuery": "New York, USA", | |
#... other parameters you've mentioned | |
} | |
run = apify_client.actor("mc9KJTQJg3zfQpANg/nwua9Gu5YrADL7ZDj").call(run_input=run_input) | |
items = [item for item in apify_client.dataset(run["defaultDatasetId"]).iterate_items()] | |
return items | |
# 3. Weather API Integration | |
def fetch_weather_data(lat, lon): | |
url = f"https://api.openweathermap.org/data/3.0/onecall?lat={lat}&lon={lon}&appid={WEATHER_KEY}" | |
response = requests.get(url) | |
data = response.json() | |
return data | |
if website_name: | |
google_maps_data = fetch_google_maps_info(website_name) | |
# Presenting Google Maps data in a Streamlit table | |
st.subheader("Google Maps Data:") | |
st.table(google_maps_data) | |
# Extracting lat and lon and fetching weather data | |
lat, lon = google_maps_data[0]['location']['lat'], google_maps_data[0]['location']['lon'] | |
weather_data = fetch_weather_data(lat, lon) | |
# Display the fetched weather data | |
st.subheader("Weather Data:") | |
st.write(weather_data['current']) # Displaying current weather data, but you can format this as needed. | |
# Displaying the place location on a Streamlit map | |
st.subheader("Place Location:") | |
st.map({"lat": lat, "lon": lon}) |