antfraia commited on
Commit
218aec2
·
1 Parent(s): b13513a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -14,25 +14,28 @@ def fetch_google_maps_results(query=None, search_type="search"):
14
  "q": query
15
  }
16
 
17
-
18
-
19
-
20
-
21
-
22
  search = GoogleSearch(params)
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 to fetch results from Google Maps.")
28
 
29
  # Input field
30
-
31
  query = st.text_input("Search Query (q): (Use for regular Google Maps search)")
32
 
33
-
34
-
35
-
36
  # Button to trigger the API call
37
  if st.button("Search"):
38
  if not query:
@@ -40,6 +43,8 @@ if st.button("Search"):
40
  else:
41
  try:
42
  results = fetch_google_maps_results(query=query)
43
- st.write(results) # Display the results
 
 
44
  except Exception as e:
45
  st.error(f"Couldn't fetch the results. Error: {e}")
 
14
  "q": query
15
  }
16
 
 
 
 
 
 
17
  search = GoogleSearch(params)
18
  results = search.get_dict()
19
  return results
20
 
21
+ def display_user_reviews(user_reviews):
22
+ st.subheader("User Reviews:")
23
+ if not user_reviews:
24
+ st.write("No reviews found.")
25
+ else:
26
+ for index, review in enumerate(user_reviews, start=1):
27
+ st.write(f"Review {index}:")
28
+ st.write(f"Username: {review.get('username', 'N/A')}")
29
+ st.write(f"Rating: {review.get('rating', 'N/A')}")
30
+ st.write(f"Description: {review.get('description', 'N/A')}")
31
+ st.write("----")
32
+
33
  st.title("Google Maps API Search via SerpAPI")
34
  st.write("Enter a search query to fetch results from Google Maps.")
35
 
36
  # Input field
 
37
  query = st.text_input("Search Query (q): (Use for regular Google Maps search)")
38
 
 
 
 
39
  # Button to trigger the API call
40
  if st.button("Search"):
41
  if not query:
 
43
  else:
44
  try:
45
  results = fetch_google_maps_results(query=query)
46
+ user_reviews = results.get("user_reviews", [])
47
+
48
+ display_user_reviews(user_reviews) # Display user reviews
49
  except Exception as e:
50
  st.error(f"Couldn't fetch the results. Error: {e}")