Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import pandas as pd
|
|
| 3 |
import requests
|
| 4 |
from apify_client import ApifyClient
|
| 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]}
|
|
@@ -18,7 +18,7 @@ def fetch_weather_info(lat, lon):
|
|
| 18 |
response = requests.get(url)
|
| 19 |
return response.json()
|
| 20 |
|
| 21 |
-
# Function to fetch website content using the
|
| 22 |
def fetch_website_content(website_url):
|
| 23 |
apify_client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
|
| 24 |
run_input = {}
|
|
@@ -26,6 +26,20 @@ def fetch_website_content(website_url):
|
|
| 26 |
items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
|
| 27 |
return items if items else None
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
# Streamlit app for Data Visualization
|
| 30 |
st.title("Data Visualization")
|
| 31 |
|
|
@@ -72,11 +86,15 @@ if website_name:
|
|
| 72 |
review_distribution = google_maps_data.get('reviewsDistribution', {})
|
| 73 |
st.bar_chart(pd.Series(review_distribution))
|
| 74 |
|
| 75 |
-
#
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
# Fetch and Display Website Content
|
| 82 |
st.subheader("Website Content")
|
|
|
|
| 3 |
import requests
|
| 4 |
from apify_client import ApifyClient
|
| 5 |
|
| 6 |
+
# Function to fetch Google Maps info using the updated actor
|
| 7 |
def fetch_google_maps_info(website_name):
|
| 8 |
apify_client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
|
| 9 |
run_input = {"searchStringsArray": [website_name]}
|
|
|
|
| 18 |
response = requests.get(url)
|
| 19 |
return response.json()
|
| 20 |
|
| 21 |
+
# Function to fetch website content using the updated actor
|
| 22 |
def fetch_website_content(website_url):
|
| 23 |
apify_client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
|
| 24 |
run_input = {}
|
|
|
|
| 26 |
items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
|
| 27 |
return items if items else None
|
| 28 |
|
| 29 |
+
# Function to fetch reviews using the new actor
|
| 30 |
+
def fetch_customer_reviews(google_maps_url):
|
| 31 |
+
apify_client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
|
| 32 |
+
run_input = {
|
| 33 |
+
"startUrls": [{"url": google_maps_url}],
|
| 34 |
+
"maxReviews": 100,
|
| 35 |
+
"reviewsSort": "newest",
|
| 36 |
+
"language": "en",
|
| 37 |
+
"personalData": True,
|
| 38 |
+
}
|
| 39 |
+
run = apify_client.actor("Xb8osYTtOjlsgI6k9").call(run_input=run_input)
|
| 40 |
+
items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
|
| 41 |
+
return items
|
| 42 |
+
|
| 43 |
# Streamlit app for Data Visualization
|
| 44 |
st.title("Data Visualization")
|
| 45 |
|
|
|
|
| 86 |
review_distribution = google_maps_data.get('reviewsDistribution', {})
|
| 87 |
st.bar_chart(pd.Series(review_distribution))
|
| 88 |
|
| 89 |
+
# Fetch customer reviews from the new API
|
| 90 |
+
google_maps_url = google_maps_data.get('url')
|
| 91 |
+
reviews_data = fetch_customer_reviews(google_maps_url)
|
| 92 |
+
progress_bar.progress(75)
|
| 93 |
+
|
| 94 |
+
# Display the reviews from the new API
|
| 95 |
+
reviews_df = pd.DataFrame(reviews_data)
|
| 96 |
+
st.subheader("Customer Reviews from New API")
|
| 97 |
+
st.table(reviews_df)
|
| 98 |
|
| 99 |
# Fetch and Display Website Content
|
| 100 |
st.subheader("Website Content")
|