Update app.py
Browse files
app.py
CHANGED
|
@@ -4,14 +4,6 @@ from requests.exceptions import HTTPError
|
|
| 4 |
|
| 5 |
def fetch_google_maps_results(query=None, search_type="search"):
|
| 6 |
if not query:
|
| 7 |
-
raise ValueError("The 'query' must be provided.")
|
| 8 |
-
|
| 9 |
-
params = {
|
| 10 |
-
"api_key": "b18f4d37042ab8222028830ee1d3db47481ac48f545382eacd7f0469414f1b1a",
|
| 11 |
-
"type": search_type,
|
| 12 |
-
"google_domain": "google.it",
|
| 13 |
-
"hl": "it",
|
| 14 |
-
"gl": "it",
|
| 15 |
"q": query
|
| 16 |
}
|
| 17 |
|
|
@@ -22,16 +14,24 @@ def fetch_google_maps_results(query=None, search_type="search"):
|
|
| 22 |
|
| 23 |
return jsonResponse
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
st.title("Google Maps API Search via SerpAPI")
|
| 26 |
st.write("Enter a search query to fetch results from Google Maps.")
|
| 27 |
|
| 28 |
# Input field
|
|
|
|
| 29 |
query = st.text_input("Search Query (q): (Use for regular Google Maps search)")
|
| 30 |
|
|
|
|
|
|
|
|
|
|
| 31 |
# Button to trigger the API call
|
| 32 |
if st.button("Search"):
|
| 33 |
if not query:
|
| 34 |
-
st.error("Please enter a search query.")
|
| 35 |
else:
|
| 36 |
try:
|
| 37 |
results = fetch_google_maps_results(query=query)
|
|
|
|
| 4 |
|
| 5 |
def fetch_google_maps_results(query=None, search_type="search"):
|
| 6 |
if not query:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
"q": query
|
| 8 |
}
|
| 9 |
|
|
|
|
| 14 |
|
| 15 |
return jsonResponse
|
| 16 |
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
|
| 22 |
st.title("Google Maps API Search via SerpAPI")
|
| 23 |
st.write("Enter a search query to fetch results from Google Maps.")
|
| 24 |
|
| 25 |
# Input field
|
| 26 |
+
|
| 27 |
query = st.text_input("Search Query (q): (Use for regular Google Maps search)")
|
| 28 |
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
|
| 32 |
# Button to trigger the API call
|
| 33 |
if st.button("Search"):
|
| 34 |
if not query:
|
|
|
|
| 35 |
else:
|
| 36 |
try:
|
| 37 |
results = fetch_google_maps_results(query=query)
|