Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,18 +13,18 @@ def fetch_google_maps_info(website_name):
|
|
13 |
|
14 |
# Function to fetch weather info
|
15 |
def fetch_weather_info(lat, lon):
|
16 |
-
API_KEY = "
|
17 |
url = f"https://api.openweathermap.org/data/3.0/onecall?lat={lat}&lon={lon}&exclude=hourly,daily&appid={API_KEY}"
|
18 |
response = requests.get(url)
|
19 |
return response.json()
|
20 |
|
21 |
# Function to fetch website content
|
22 |
def fetch_website_content(website_url):
|
23 |
-
apify_client = ApifyClient("
|
24 |
run_input = {}
|
25 |
run = apify_client.actor("mc9KJTQJg3zfQpANg/aYG0l9s7dbB7j3gbS").call(run_input=run_input)
|
26 |
items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
|
27 |
-
return items
|
28 |
|
29 |
# Streamlit app
|
30 |
st.title("Data Visualization")
|
@@ -46,10 +46,12 @@ if website_name:
|
|
46 |
st.map(pd.DataFrame({'lat': [lat], 'lon': [lng]})) # Display the map
|
47 |
weather_data = fetch_weather_info(lat, lng)
|
48 |
current_weather = weather_data.get("current", {})
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
53 |
|
54 |
# Occupancy Data
|
55 |
st.subheader("Occupancy Data")
|
@@ -64,10 +66,8 @@ if website_name:
|
|
64 |
# Review Count and Distribution
|
65 |
st.subheader("Review Count and Distribution")
|
66 |
st.write(f"Total Reviews Count: {google_maps_data['reviewsCount']}")
|
67 |
-
review_distribution = google_maps_data
|
68 |
-
|
69 |
-
ordered_distribution = {day: review_distribution.get(day, 0) for day in days_order}
|
70 |
-
st.bar_chart(pd.Series(ordered_distribution), use_container_width=True)
|
71 |
|
72 |
# Reviews Table
|
73 |
st.subheader("Customer Reviews")
|
@@ -82,9 +82,10 @@ if website_name:
|
|
82 |
st.subheader("Website Content")
|
83 |
website_content_data = fetch_website_content(website_link)
|
84 |
if website_content_data:
|
85 |
-
|
|
|
86 |
else:
|
87 |
st.write("Unable to retrieve website content.")
|
88 |
|
89 |
else:
|
90 |
-
st.write("No results found for this website / company name on Google Maps.")
|
|
|
13 |
|
14 |
# Function to fetch weather info
|
15 |
def fetch_weather_info(lat, lon):
|
16 |
+
API_KEY = "91b23cab82ee530b2052c8757e343b0d"
|
17 |
url = f"https://api.openweathermap.org/data/3.0/onecall?lat={lat}&lon={lon}&exclude=hourly,daily&appid={API_KEY}"
|
18 |
response = requests.get(url)
|
19 |
return response.json()
|
20 |
|
21 |
# Function to fetch website content
|
22 |
def fetch_website_content(website_url):
|
23 |
+
apify_client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
|
24 |
run_input = {}
|
25 |
run = apify_client.actor("mc9KJTQJg3zfQpANg/aYG0l9s7dbB7j3gbS").call(run_input=run_input)
|
26 |
items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
|
27 |
+
return items if items else None
|
28 |
|
29 |
# Streamlit app
|
30 |
st.title("Data Visualization")
|
|
|
46 |
st.map(pd.DataFrame({'lat': [lat], 'lon': [lng]})) # Display the map
|
47 |
weather_data = fetch_weather_info(lat, lng)
|
48 |
current_weather = weather_data.get("current", {})
|
49 |
+
temp = current_weather.get('temp')
|
50 |
+
if temp:
|
51 |
+
temp_in_celsius = temp - 273.15
|
52 |
+
st.write(f"**Location:** {lat}, {lng}")
|
53 |
+
st.write(f"**Temperature:** {temp_in_celsius:.2f}°C")
|
54 |
+
st.write(f"**Weather:** {current_weather.get('weather')[0].get('description')}")
|
55 |
|
56 |
# Occupancy Data
|
57 |
st.subheader("Occupancy Data")
|
|
|
66 |
# Review Count and Distribution
|
67 |
st.subheader("Review Count and Distribution")
|
68 |
st.write(f"Total Reviews Count: {google_maps_data['reviewsCount']}")
|
69 |
+
review_distribution = google_maps_data.get('reviewsDistribution', {})
|
70 |
+
st.bar_chart(pd.Series(review_distribution), use_container_width=True)
|
|
|
|
|
71 |
|
72 |
# Reviews Table
|
73 |
st.subheader("Customer Reviews")
|
|
|
82 |
st.subheader("Website Content")
|
83 |
website_content_data = fetch_website_content(website_link)
|
84 |
if website_content_data:
|
85 |
+
website_df = pd.DataFrame(website_content_data)
|
86 |
+
st.table(website_df)
|
87 |
else:
|
88 |
st.write("Unable to retrieve website content.")
|
89 |
|
90 |
else:
|
91 |
+
st.write("No results found for this website / company name on Google Maps.")
|