Update app.py
Browse files
app.py
CHANGED
@@ -58,21 +58,20 @@ if st.session_state["reply"]:
|
|
58 |
st.markdown("<h2 style='text-align: center; color: black;'>Recommended Neighborhoods ⬇️</h2>", unsafe_allow_html=True)
|
59 |
st.write(st.session_state["reply"])
|
60 |
|
61 |
-
# Extract
|
62 |
neighborhoods = []
|
63 |
for line in st.session_state["reply"].splitlines():
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
67 |
neighborhoods.append(location)
|
68 |
|
69 |
-
#
|
70 |
-
st.write("Extracted Neighborhoods:", neighborhoods)
|
71 |
-
|
72 |
-
# Display Zillow links, ensuring neighborhood and city are included in each URL
|
73 |
st.markdown("### Zillow Search Links")
|
74 |
for location in neighborhoods:
|
75 |
-
#
|
76 |
full_location_query = urllib.parse.quote(location)
|
77 |
zillow_url = f"https://www.zillow.com/homes/{full_location_query}_rb/"
|
78 |
|
|
|
58 |
st.markdown("<h2 style='text-align: center; color: black;'>Recommended Neighborhoods ⬇️</h2>", unsafe_allow_html=True)
|
59 |
st.write(st.session_state["reply"])
|
60 |
|
61 |
+
# Extract only lines with the format "Neighborhood, City, State:"
|
62 |
neighborhoods = []
|
63 |
for line in st.session_state["reply"].splitlines():
|
64 |
+
if line and "," in line and ":" in line: # Ensure it matches "Neighborhood, City, State:"
|
65 |
+
location = line.split(":")[0].strip() # Capture up to the first colon
|
66 |
+
# Remove any numbering
|
67 |
+
if location[0].isdigit():
|
68 |
+
location = location.split(" ", 1)[1].strip()
|
69 |
neighborhoods.append(location)
|
70 |
|
71 |
+
# Display Zillow links
|
|
|
|
|
|
|
72 |
st.markdown("### Zillow Search Links")
|
73 |
for location in neighborhoods:
|
74 |
+
# Format the search query correctly
|
75 |
full_location_query = urllib.parse.quote(location)
|
76 |
zillow_url = f"https://www.zillow.com/homes/{full_location_query}_rb/"
|
77 |
|