Nusri7 commited on
Commit
7e7dbe4
Β·
verified Β·
1 Parent(s): b3fe6ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -9
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", "Rajagiriya, Sri Lanka")
123
  with col2:
124
  search_radius_km = st.slider("πŸ” Search Radius (km)", 1, 20, 2)
125
 
126
- business_query = st.text_input("🏒 Your Business Name", "")
127
- website_url = st.text_input("🌐 Your Website URL", "", help="Enter your website to check if it appears in search results")
 
 
128
 
129
  if business_query:
130
  suggestions = get_business_suggestions(business_query, location)
131
  if suggestions:
 
 
 
132
  business_selection = st.selectbox(
133
- "πŸ”Ž Select Your Business",
134
- options=[s["name"] for s in suggestions],
135
- index=0
 
 
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
- keywords_input = st.text_input("πŸ“Œ Search Keywords (comma separated)", "coffee shop, cafe, breakfast place")
 
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: