Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -99,7 +99,7 @@ def get_serp_rankings(keyword, location, website_url=None):
|
|
99 |
def save_to_excel(data, filename="my_website_rankings.xlsx"):
|
100 |
try:
|
101 |
df = pd.DataFrame(data)
|
102 |
-
df.to_excel(filename, index=False)
|
103 |
st.success(f"β
Your website rankings saved to **{filename}**")
|
104 |
st.download_button(
|
105 |
label="π₯ Download Excel File",
|
@@ -119,30 +119,38 @@ st.markdown("Check your business ranking on Google Maps and search results")
|
|
119 |
with st.form("search_form"):
|
120 |
col1, col2 = st.columns(2)
|
121 |
with col1:
|
122 |
-
location = st.text_input("π Target Location", "
|
123 |
with col2:
|
124 |
search_radius_km = st.slider("π Search Radius (km)", 1, 20, 2)
|
125 |
|
126 |
-
|
127 |
-
|
|
|
|
|
128 |
|
129 |
if business_query:
|
130 |
suggestions = get_business_suggestions(business_query, location)
|
131 |
if suggestions:
|
|
|
|
|
|
|
132 |
business_selection = st.selectbox(
|
133 |
-
"π Select
|
134 |
-
options=
|
135 |
-
index=
|
|
|
|
|
136 |
)
|
137 |
business_place_id = next(s["place_id"] for s in suggestions if s["name"] == business_selection)
|
138 |
else:
|
139 |
st.warning("No matching businesses found")
|
140 |
|
141 |
-
|
|
|
142 |
|
143 |
submitted = st.form_submit_button("π Check Rankings")
|
144 |
|
145 |
-
if submitted and business_query:
|
146 |
keywords = [kw.strip() for kw in keywords_input.split(",") if kw.strip()]
|
147 |
|
148 |
if not keywords:
|
|
|
99 |
def save_to_excel(data, filename="my_website_rankings.xlsx"):
|
100 |
try:
|
101 |
df = pd.DataFrame(data)
|
102 |
+
df.to_excel(filename, index=False, engine='openpyxl')
|
103 |
st.success(f"β
Your website rankings saved to **{filename}**")
|
104 |
st.download_button(
|
105 |
label="π₯ Download Excel File",
|
|
|
119 |
with st.form("search_form"):
|
120 |
col1, col2 = st.columns(2)
|
121 |
with col1:
|
122 |
+
location = st.text_input("π Target Location", "Nottingham, MD, USA")
|
123 |
with col2:
|
124 |
search_radius_km = st.slider("π Search Radius (km)", 1, 20, 2)
|
125 |
|
126 |
+
# Combined business name input with autocomplete dropdown
|
127 |
+
business_query = st.text_input("π’ Your Business Name", "", key="business_query")
|
128 |
+
business_place_id = None
|
129 |
+
business_selection = None
|
130 |
|
131 |
if business_query:
|
132 |
suggestions = get_business_suggestions(business_query, location)
|
133 |
if suggestions:
|
134 |
+
# Create a selectbox that appears below the input field
|
135 |
+
selected_index = 0
|
136 |
+
options = [s["name"] for s in suggestions]
|
137 |
business_selection = st.selectbox(
|
138 |
+
"π Select from suggestions",
|
139 |
+
options=options,
|
140 |
+
index=selected_index,
|
141 |
+
key="business_selection",
|
142 |
+
label_visibility="collapsed" # Hide the label
|
143 |
)
|
144 |
business_place_id = next(s["place_id"] for s in suggestions if s["name"] == business_selection)
|
145 |
else:
|
146 |
st.warning("No matching businesses found")
|
147 |
|
148 |
+
website_url = st.text_input("π Your Website URL", "", help="Enter your website to check if it appears in search results")
|
149 |
+
keywords_input = st.text_input("π Search Keywords (comma separated)", "Phone repair, mobile repair")
|
150 |
|
151 |
submitted = st.form_submit_button("π Check Rankings")
|
152 |
|
153 |
+
if submitted and business_query and business_place_id:
|
154 |
keywords = [kw.strip() for kw in keywords_input.split(",") if kw.strip()]
|
155 |
|
156 |
if not keywords:
|