File size: 2,055 Bytes
3e996d0
ba1946b
932e360
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from apify_client import ApifyClient
import requests

# API Keys
APIFY_KEY = 'apify_api_uz0y556N4IG2aLcESj67kmnGSUpHF12XAkLp'
WEATHER_KEY = '91b23cab82ee530b2052c8757e343b0d'

# Set up clients
apify_client = ApifyClient(APIFY_KEY)

st.title("Comprehensive Place Summary App")
website_name = st.text_input("Enter website / company name:")

# 1. Website API Integration (if needed in the future)
def fetch_website_content(website_name):
    run = apify_client.actor("mc9KJTQJg3zfQpANg/aYG0l9s7dbB7j3gbS").call(run_input={})
    items = [item for item in apify_client.dataset(run["defaultDatasetId"]).iterate_items()]
    return items

# 2. Google Maps API Integration
def fetch_google_maps_info(website_name):
    run_input = {
        "searchStringsArray": [website_name],
        "locationQuery": "New York, USA",
        #... other parameters you've mentioned
    }
    run = apify_client.actor("mc9KJTQJg3zfQpANg/nwua9Gu5YrADL7ZDj").call(run_input=run_input)
    items = [item for item in apify_client.dataset(run["defaultDatasetId"]).iterate_items()]
    return items

# 3. Weather API Integration
def fetch_weather_data(lat, lon):
    url = f"https://api.openweathermap.org/data/3.0/onecall?lat={lat}&lon={lon}&appid={WEATHER_KEY}"
    response = requests.get(url)
    data = response.json()
    return data

if website_name:
    google_maps_data = fetch_google_maps_info(website_name)
    
    # Presenting Google Maps data in a Streamlit table
    st.subheader("Google Maps Data:")
    st.table(google_maps_data)

    # Extracting lat and lon and fetching weather data
    lat, lon = google_maps_data[0]['location']['lat'], google_maps_data[0]['location']['lon']
    weather_data = fetch_weather_data(lat, lon)
    
    # Display the fetched weather data
    st.subheader("Weather Data:")
    st.write(weather_data['current'])  # Displaying current weather data, but you can format this as needed.

    # Displaying the place location on a Streamlit map
    st.subheader("Place Location:")
    st.map({"lat": lat, "lon": lon})