antfraia commited on
Commit
b13513a
·
1 Parent(s): 6e5d2f2

Update app.py

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