antfraia commited on
Commit
46a426c
·
1 Parent(s): 0710745

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -1,8 +1,7 @@
1
  import streamlit as st
2
  import pandas as pd
3
- import numpy as np
4
- from apify_client import ApifyClient
5
  import requests
 
6
 
7
  # Function to fetch Google Maps info
8
  def fetch_google_maps_info(website_name):
@@ -12,21 +11,21 @@ def fetch_google_maps_info(website_name):
12
  items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
13
  return items[0] if items else None
14
 
15
- # Function to fetch website content using Apify actor
16
- def fetch_website_content(website_url):
17
- apify_client = ApifyClient("apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp")
18
- run_input = {"startUrls": [website_url]}
19
- run = apify_client.actor("moJRLRc85AitArpNN").call(run_input=run_input)
20
- items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
21
- return items[0] if items else None
22
-
23
  # Function to fetch weather info
24
  def fetch_weather_info(lat, lon):
25
- API_KEY = "91b23cab82ee530b2052c8757e343b0d"
26
  url = f"https://api.openweathermap.org/data/3.0/onecall?lat={lat}&lon={lon}&exclude=hourly,daily&appid={API_KEY}"
27
  response = requests.get(url)
28
  return response.json()
29
 
 
 
 
 
 
 
 
 
30
  # Streamlit app
31
  st.title("Data Visualization")
32
 
@@ -40,13 +39,6 @@ if website_name:
40
  website_link = google_maps_data.get('website')
41
  st.text_area("Website Link:", website_link)
42
 
43
- # Fetch and display website content
44
- website_content = fetch_website_content(website_link)
45
- if website_content:
46
- st.subheader("Scraped Website Content")
47
- content_df = pd.DataFrame(website_content)
48
- st.table(content_df)
49
-
50
  # Display location and fetch weather info
51
  lat = google_maps_data["location"]["lat"]
52
  lng = google_maps_data["location"]["lng"]
@@ -85,6 +77,14 @@ if website_name:
85
  st.table(review_df[['name', 'text', 'publishAt', 'likesCount', 'stars']])
86
  else:
87
  st.write("No reviews available.")
 
 
 
 
 
 
 
 
88
 
89
  else:
90
- 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
7
  def fetch_google_maps_info(website_name):
 
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
15
  def fetch_weather_info(lat, lon):
16
+ API_KEY = "apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp"
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
22
+ def fetch_website_content(website_url):
23
+ apify_client = ApifyClient("<YOUR_API_TOKEN>")
24
+ run_input = {}
25
+ run = apify_client.actor("mc9KJTQJg3zfQpANg/aYG0l9s7dbB7j3gbS").call(run_input=run_input)
26
+ items = list(apify_client.dataset(run["defaultDatasetId"]).iterate_items())
27
+ return items[0] if items else None
28
+
29
  # Streamlit app
30
  st.title("Data Visualization")
31
 
 
39
  website_link = google_maps_data.get('website')
40
  st.text_area("Website Link:", website_link)
41
 
 
 
 
 
 
 
 
42
  # Display location and fetch weather info
43
  lat = google_maps_data["location"]["lat"]
44
  lng = google_maps_data["location"]["lng"]
 
77
  st.table(review_df[['name', 'text', 'publishAt', 'likesCount', 'stars']])
78
  else:
79
  st.write("No reviews available.")
80
+
81
+ # Website Content
82
+ st.subheader("Website Content")
83
+ website_content_data = fetch_website_content(website_link)
84
+ if website_content_data:
85
+ st.table(pd.DataFrame(website_content_data))
86
+ else:
87
+ st.write("Unable to retrieve website content.")
88
 
89
  else:
90
+ st.write("No results found for this website / company name on Google Maps.")