Update app.py
Browse files
app.py
CHANGED
@@ -23,25 +23,13 @@ def fetch_google_maps_results(query=None, location=None, search_type="search"):
|
|
23 |
results = search.get_dict()
|
24 |
return results
|
25 |
|
26 |
-
def display_reviews(results):
|
27 |
-
# Extract customer reviews
|
28 |
-
reviews = results.get('reviews', [])
|
29 |
-
|
30 |
-
if reviews:
|
31 |
-
for review in reviews:
|
32 |
-
st.write("Reviewer:", review.get('author'))
|
33 |
-
st.write("Rating:", review.get('rating'))
|
34 |
-
st.write("Review:", review.get('text'))
|
35 |
-
st.write('---') # Line separator for better readability
|
36 |
-
else:
|
37 |
-
st.write("No reviews found.")
|
38 |
-
|
39 |
st.title("Google Maps API Search via SerpAPI")
|
40 |
st.write("Enter a search query or a geographic location to fetch results from Google Maps.")
|
41 |
|
42 |
# Input fields
|
43 |
search_type = st.selectbox("Select Search Type:", ["search", "place"])
|
44 |
query = st.text_input("Search Query (q): (Use for regular Google Maps search)")
|
|
|
45 |
location = st.text_input("Geographic Location (ll): (Format: '@latitude,longitude,zoom')")
|
46 |
|
47 |
# Button to trigger the API call
|
@@ -51,6 +39,7 @@ if st.button("Search"):
|
|
51 |
else:
|
52 |
try:
|
53 |
results = fetch_google_maps_results(query=query, location=location, search_type=search_type)
|
54 |
-
|
|
|
55 |
except Exception as e:
|
56 |
-
st.error(f"Couldn't fetch the results. Error: {e}")
|
|
|
23 |
results = search.get_dict()
|
24 |
return results
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
st.title("Google Maps API Search via SerpAPI")
|
27 |
st.write("Enter a search query or a geographic location to fetch results from Google Maps.")
|
28 |
|
29 |
# Input fields
|
30 |
search_type = st.selectbox("Select Search Type:", ["search", "place"])
|
31 |
query = st.text_input("Search Query (q): (Use for regular Google Maps search)")
|
32 |
+
|
33 |
location = st.text_input("Geographic Location (ll): (Format: '@latitude,longitude,zoom')")
|
34 |
|
35 |
# Button to trigger the API call
|
|
|
39 |
else:
|
40 |
try:
|
41 |
results = fetch_google_maps_results(query=query, location=location, search_type=search_type)
|
42 |
+
# Display the results (you might want to format or filter this)
|
43 |
+
st.write(results)
|
44 |
except Exception as e:
|
45 |
+
st.error(f"Couldn't fetch the results. Error: {e}")
|