Spaces:
Sleeping
Sleeping
File size: 2,815 Bytes
3e996d0 e6ac219 c7f1dd0 d24c8e2 932e360 d24c8e2 0710745 d24c8e2 0710745 d24c8e2 c7f1dd0 d24c8e2 c7f1dd0 46a426c 036ebf1 e6ac219 036ebf1 0710745 d24c8e2 036ebf1 0710745 d24c8e2 c7f1dd0 0710745 c7f1dd0 d24c8e2 c7f1dd0 d24c8e2 c7f1dd0 d24c8e2 fce2a17 ef76fa0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
import streamlit as st
import pandas as pd
import requests
from apify_client import ApifyClient
# Function to fetch Google Maps info using the nwua9Gu5YrADL7ZDj actor
def fetch_google_maps_info(website_name):
apify_client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
run_input = {"searchStringsArray": [website_name]}
run = apify_client.actor("nwua9Gu5YrADL7ZDj").call(run_input=run_input)
items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
return items[0] if items else None
# Function to fetch weather info from OpenWeatherMap API
def fetch_weather_info(lat, lon):
API_KEY = "91b23cab82ee530b2052c8757e343b0d"
url = f"https://api.openweathermap.org/data/3.0/onecall?lat={lat}&lon={lon}&exclude=hourly,daily&appid={API_KEY}"
response = requests.get(url)
return response.json()
# Function to fetch website content using the moJRLRc85AitArpNN actor
def fetch_website_content(website_url):
apify_client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
run_input = {"url": website_url}
run = apify_client.actor("moJRLRc85AitArpNN").call(run_input=run_input)
items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
return items if items else None
# Function to fetch customer reviews using the Xb8osYTtOjlsgI6k9 actor
def fetch_customer_reviews(location_query):
client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
run_input = {
"searchStringsArray": ["restaurant"],
"locationQuery": location_query,
"language": "en",
}
run = client.actor("Xb8osYTtOjlsgI6k9").call(run_input=run_input)
return list(client.dataset(run["defaultDatasetId"]).iterate_items())
# Streamlit app for Data Visualization
st.title("Data Visualization")
# Input for website or company name
website_name = st.text_input("Enter a website / company name:")
if website_name:
# Initialize the progress bar
progress_bar = st.progress(0)
# Fetch Google Maps data
google_maps_data = fetch_google_maps_info(website_name)
progress_bar.progress(33)
if google_maps_data:
location_query = google_maps_data.get("locationQuery")
reviews_data = fetch_customer_reviews(location_query)
progress_bar.progress(66)
# Display the rest of the Google Maps data
# ... (use the original display code for Google Maps data here) ...
# Display reviews_data from the new API
reviews_df = pd.DataFrame(reviews_data)
st.subheader("Customer Reviews from New API")
st.table(reviews_df[['name', 'text', 'publishAt', 'likesCount', 'stars']])
progress_bar.progress(100)
else:
st.write("No results found for this website / company name on Google Maps.") |