Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,45 +1,40 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
-
from apify_client import ApifyClient
|
4 |
import requests
|
|
|
5 |
|
6 |
-
# Function to fetch Google Maps info using the
|
7 |
def fetch_google_maps_info(website_name):
|
8 |
apify_client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
|
9 |
run_input = {"searchStringsArray": [website_name]}
|
10 |
-
run = apify_client.actor("
|
11 |
items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
|
12 |
return items[0] if items else None
|
13 |
|
14 |
-
# Function to fetch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
def fetch_customer_reviews(location_query):
|
16 |
client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
|
17 |
run_input = {
|
18 |
"searchStringsArray": ["restaurant"],
|
19 |
"locationQuery": location_query,
|
20 |
-
"maxCrawledPlacesPerSearch": 50,
|
21 |
"language": "en",
|
22 |
-
"maxImages": None,
|
23 |
-
"onlyDataFromSearchPage": False,
|
24 |
-
"includeWebResults": False,
|
25 |
-
"deeperCityScrape": False,
|
26 |
-
"maxReviews": None,
|
27 |
-
"oneReviewPerRow": False,
|
28 |
-
"reviewsSort": "newest",
|
29 |
-
"reviewsFilterString": "",
|
30 |
-
"scrapeReviewerName": True,
|
31 |
-
"scrapeReviewerId": True,
|
32 |
-
"scrapeReviewerUrl": True,
|
33 |
-
"scrapeReviewId": True,
|
34 |
-
"scrapeReviewUrl": True,
|
35 |
-
"scrapeResponseFromOwnerText": True,
|
36 |
-
"countryCode": None,
|
37 |
-
"searchMatching": "all",
|
38 |
-
"placeMinimumStars": "",
|
39 |
-
"skipClosedPlaces": False,
|
40 |
-
"allPlacesNoSearchAction": "",
|
41 |
}
|
42 |
-
run = client.actor("
|
43 |
return list(client.dataset(run["defaultDatasetId"]).iterate_items())
|
44 |
|
45 |
# Streamlit app for Data Visualization
|
@@ -49,19 +44,26 @@ st.title("Data Visualization")
|
|
49 |
website_name = st.text_input("Enter a website / company name:")
|
50 |
|
51 |
if website_name:
|
|
|
|
|
|
|
52 |
# Fetch Google Maps data
|
53 |
google_maps_data = fetch_google_maps_info(website_name)
|
|
|
54 |
|
55 |
if google_maps_data:
|
56 |
location_query = google_maps_data.get("locationQuery")
|
57 |
reviews_data = fetch_customer_reviews(location_query)
|
58 |
-
|
59 |
-
|
|
|
60 |
# ... (use the original display code for Google Maps data here) ...
|
61 |
-
|
62 |
-
# Display reviews_data
|
63 |
-
|
64 |
st.subheader("Customer Reviews from New API")
|
65 |
-
st.table(
|
|
|
|
|
66 |
else:
|
67 |
st.write("No results found for this website / company name on Google Maps.")
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
|
|
3 |
import requests
|
4 |
+
from apify_client import ApifyClient
|
5 |
|
6 |
+
# Function to fetch Google Maps info using the nwua9Gu5YrADL7ZDj actor
|
7 |
def fetch_google_maps_info(website_name):
|
8 |
apify_client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
|
9 |
run_input = {"searchStringsArray": [website_name]}
|
10 |
+
run = apify_client.actor("nwua9Gu5YrADL7ZDj").call(run_input=run_input)
|
11 |
items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
|
12 |
return items[0] if items else None
|
13 |
|
14 |
+
# Function to fetch weather info from OpenWeatherMap API
|
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 using the moJRLRc85AitArpNN actor
|
22 |
+
def fetch_website_content(website_url):
|
23 |
+
apify_client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
|
24 |
+
run_input = {"url": website_url}
|
25 |
+
run = apify_client.actor("moJRLRc85AitArpNN").call(run_input=run_input)
|
26 |
+
items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
|
27 |
+
return items if items else None
|
28 |
+
|
29 |
+
# Function to fetch customer reviews using the Xb8osYTtOjlsgI6k9 actor
|
30 |
def fetch_customer_reviews(location_query):
|
31 |
client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
|
32 |
run_input = {
|
33 |
"searchStringsArray": ["restaurant"],
|
34 |
"locationQuery": location_query,
|
|
|
35 |
"language": "en",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
+
run = client.actor("Xb8osYTtOjlsgI6k9").call(run_input=run_input)
|
38 |
return list(client.dataset(run["defaultDatasetId"]).iterate_items())
|
39 |
|
40 |
# Streamlit app for Data Visualization
|
|
|
44 |
website_name = st.text_input("Enter a website / company name:")
|
45 |
|
46 |
if website_name:
|
47 |
+
# Initialize the progress bar
|
48 |
+
progress_bar = st.progress(0)
|
49 |
+
|
50 |
# Fetch Google Maps data
|
51 |
google_maps_data = fetch_google_maps_info(website_name)
|
52 |
+
progress_bar.progress(33)
|
53 |
|
54 |
if google_maps_data:
|
55 |
location_query = google_maps_data.get("locationQuery")
|
56 |
reviews_data = fetch_customer_reviews(location_query)
|
57 |
+
progress_bar.progress(66)
|
58 |
+
|
59 |
+
# Display the rest of the Google Maps data
|
60 |
# ... (use the original display code for Google Maps data here) ...
|
61 |
+
|
62 |
+
# Display reviews_data from the new API
|
63 |
+
reviews_df = pd.DataFrame(reviews_data)
|
64 |
st.subheader("Customer Reviews from New API")
|
65 |
+
st.table(reviews_df[['name', 'text', 'publishAt', 'likesCount', 'stars']])
|
66 |
+
|
67 |
+
progress_bar.progress(100)
|
68 |
else:
|
69 |
st.write("No results found for this website / company name on Google Maps.")
|