Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ from apify_client import ApifyClient
|
|
3 |
import requests
|
4 |
|
5 |
def fetch_google_maps_info(website_name):
|
6 |
-
# Initialize the ApifyClient with your API token
|
7 |
apify_client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
|
8 |
|
9 |
# Prepare the Actor input for Google Maps
|
@@ -14,10 +13,10 @@ def fetch_google_maps_info(website_name):
|
|
14 |
|
15 |
# Run the Actor and wait for it to finish
|
16 |
run = apify_client.actor("nwua9Gu5YrADL7ZDj").call(run_input=run_input)
|
17 |
-
|
18 |
# Fetch Actor results from the run's dataset
|
19 |
items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
|
20 |
-
return items
|
21 |
|
22 |
def fetch_weather_info(lat, lon):
|
23 |
API_KEY = "91b23cab82ee530b2052c8757e343b0d"
|
@@ -29,21 +28,33 @@ def fetch_weather_info(lat, lon):
|
|
29 |
website_name = st.text_input("Enter a website / company name:")
|
30 |
|
31 |
if website_name:
|
32 |
-
# Fetch Google Maps data
|
33 |
google_maps_data = fetch_google_maps_info(website_name)
|
34 |
-
|
35 |
-
# Display in Streamlit table
|
36 |
if google_maps_data:
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
# Fetch weather info based on Google Maps data's location
|
40 |
-
lat = google_maps_data[
|
41 |
-
lng = google_maps_data[
|
42 |
-
|
43 |
if lat and lng:
|
44 |
# Display location on Streamlit map
|
45 |
st.map({"lat": lat, "lon": lng})
|
46 |
-
|
47 |
weather_data = fetch_weather_info(lat, lng)
|
48 |
current_weather = weather_data.get("current", {})
|
49 |
st.write(f"Temperature: {current_weather.get('temp')}°C")
|
|
|
3 |
import requests
|
4 |
|
5 |
def fetch_google_maps_info(website_name):
|
|
|
6 |
apify_client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
|
7 |
|
8 |
# Prepare the Actor input for Google Maps
|
|
|
13 |
|
14 |
# Run the Actor and wait for it to finish
|
15 |
run = apify_client.actor("nwua9Gu5YrADL7ZDj").call(run_input=run_input)
|
16 |
+
|
17 |
# Fetch Actor results from the run's dataset
|
18 |
items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
|
19 |
+
return items[0] if items else None
|
20 |
|
21 |
def fetch_weather_info(lat, lon):
|
22 |
API_KEY = "91b23cab82ee530b2052c8757e343b0d"
|
|
|
28 |
website_name = st.text_input("Enter a website / company name:")
|
29 |
|
30 |
if website_name:
|
|
|
31 |
google_maps_data = fetch_google_maps_info(website_name)
|
32 |
+
|
|
|
33 |
if google_maps_data:
|
34 |
+
# Formatting and displaying the data in Streamlit table
|
35 |
+
table_data = {
|
36 |
+
"Location": f"Lat: {google_maps_data['location']['lat']}, Lng: {google_maps_data['location']['lng']}",
|
37 |
+
"Plus Code": google_maps_data["plusCode"],
|
38 |
+
"Menu": google_maps_data["menu"],
|
39 |
+
"Total Score": google_maps_data["totalScore"],
|
40 |
+
"Permanently Closed": google_maps_data["permanentlyClosed"],
|
41 |
+
"Temporarily Closed": google_maps_data["temporarilyClosed"],
|
42 |
+
"Place ID": google_maps_data["placeId"],
|
43 |
+
"Categories": ", ".join(google_maps_data["categories"]),
|
44 |
+
"CID": google_maps_data["cid"],
|
45 |
+
"Reviews Count": google_maps_data["reviewsCount"],
|
46 |
+
}
|
47 |
+
|
48 |
+
st.table(table_data)
|
49 |
+
|
50 |
# Fetch weather info based on Google Maps data's location
|
51 |
+
lat = google_maps_data["location"]["lat"]
|
52 |
+
lng = google_maps_data["location"]["lng"]
|
53 |
+
|
54 |
if lat and lng:
|
55 |
# Display location on Streamlit map
|
56 |
st.map({"lat": lat, "lon": lng})
|
57 |
+
|
58 |
weather_data = fetch_weather_info(lat, lng)
|
59 |
current_weather = weather_data.get("current", {})
|
60 |
st.write(f"Temperature: {current_weather.get('temp')}°C")
|