antfraia commited on
Commit
e2bf5cc
·
1 Parent(s): 5e73404

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -10
app.py CHANGED
@@ -18,9 +18,9 @@ def fetch_weather_info(lat, lon):
18
  return response.json()
19
 
20
  # Function to fetch website content using the updated actor
21
- def fetch_website_content(google_maps_url):
22
  apify_client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
23
- run_input = {"startUrls": [{"url": google_maps_url}]}
24
  run = apify_client.actor("moJRLRc85AitArpNN").call(run_input=run_input)
25
  items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
26
  return items if items else None
@@ -54,21 +54,50 @@ if website_name:
54
  progress_bar.progress(50)
55
 
56
  if google_maps_data:
57
- # Fetch and Display Website Content
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  google_maps_url = google_maps_data.get('url')
59
- website_content_data = fetch_website_content(google_maps_url)
60
  progress_bar.progress(75)
 
 
 
 
 
 
 
 
 
 
61
 
62
  if website_content_data:
63
  website_df = pd.DataFrame(website_content_data)
64
  st.table(website_df)
65
  else:
66
  st.write("Unable to retrieve website content.")
67
-
68
- # Fetch customer reviews from the new API and display them
69
- reviews_data = fetch_customer_reviews(google_maps_url)
70
- reviews_df = pd.DataFrame(reviews_data)[['text']]
71
- st.subheader("Customer Reviews from New API")
72
- st.table(reviews_df)
73
  else:
74
  st.write("No results found for this website / company name on Google Maps.")
 
18
  return response.json()
19
 
20
  # Function to fetch website content using the updated actor
21
+ def fetch_website_content(website_url):
22
  apify_client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
23
+ run_input = {}
24
  run = apify_client.actor("moJRLRc85AitArpNN").call(run_input=run_input)
25
  items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
26
  return items if items else None
 
54
  progress_bar.progress(50)
55
 
56
  if google_maps_data:
57
+ # Display website link
58
+ website_link = google_maps_data.get('website')
59
+ st.text_area("Website Link:", website_link)
60
+
61
+ # Display location and fetch weather info
62
+ lat = google_maps_data["location"]["lat"]
63
+ lng = google_maps_data["location"]["lng"]
64
+ st.map(pd.DataFrame({'lat': [lat], 'lon': [lng]}))
65
+ weather_data = fetch_weather_info(lat, lng)
66
+ current_weather = weather_data.get("current", {})
67
+ temp = current_weather.get('temp')
68
+ temp_in_celsius = temp - 273.15
69
+ st.write(f"**Location:** {lat}, {lng}")
70
+ st.write(f"**Temperature:** {temp_in_celsius:.2f}°C")
71
+ st.write(f"**Weather:** {current_weather.get('weather')[0].get('description')}")
72
+
73
+ # Display Occupancy Data
74
+ st.subheader("Occupancy Data")
75
+ occupancy_data = google_maps_data.get('popularTimesHistogram', {})
76
+ for day, day_data in occupancy_data.items():
77
+ hours = [entry['hour'] for entry in day_data]
78
+ occupancy = [entry['occupancyPercent'] for entry in day_data]
79
+ st.write(day)
80
+ st.bar_chart(pd.Series(occupancy, index=hours))
81
+
82
+ # Fetch customer reviews from the new API
83
  google_maps_url = google_maps_data.get('url')
84
+ reviews_data = fetch_customer_reviews(google_maps_url)
85
  progress_bar.progress(75)
86
+
87
+ # Display the reviews from the new API
88
+ reviews_df = pd.DataFrame(reviews_data)[['text']]
89
+ st.subheader("Customer Reviews from New API")
90
+ st.table(reviews_df)
91
+
92
+ # Fetch and Display Website Content
93
+ st.subheader("Website Content")
94
+ website_content_data = fetch_website_content(website_link)
95
+ progress_bar.progress(100)
96
 
97
  if website_content_data:
98
  website_df = pd.DataFrame(website_content_data)
99
  st.table(website_df)
100
  else:
101
  st.write("Unable to retrieve website content.")
 
 
 
 
 
 
102
  else:
103
  st.write("No results found for this website / company name on Google Maps.")