Update main.py
Browse files
main.py
CHANGED
@@ -166,27 +166,37 @@ def proxy(path):
|
|
166 |
breadcrumb_div = soup.new_tag('div')
|
167 |
breadcrumb_div['class'] = 'breadcrumb'
|
168 |
|
169 |
-
|
|
|
170 |
for link in nav_links:
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
current_span = soup.new_tag('span')
|
181 |
breadcrumb_div.append(current_span)
|
182 |
-
|
183 |
-
|
184 |
-
|
|
|
|
|
185 |
|
186 |
-
# Replace old navigation with new breadcrumb
|
187 |
-
|
188 |
-
|
189 |
-
first_hr.replace_with(breadcrumb_div)
|
190 |
|
191 |
# Create a Flask response object with filtered content
|
192 |
response = Response(
|
|
|
166 |
breadcrumb_div = soup.new_tag('div')
|
167 |
breadcrumb_div['class'] = 'breadcrumb'
|
168 |
|
169 |
+
# Find the main navigation container
|
170 |
+
nav_container = None
|
171 |
for link in nav_links:
|
172 |
+
if link.parent.name == 'font' and link.parent.parent.name == 'td':
|
173 |
+
nav_container = link.parent.parent
|
174 |
+
break
|
175 |
+
|
176 |
+
if nav_container:
|
177 |
+
nav_links = nav_container.find_all('a', href=True)
|
178 |
+
current_span = None
|
179 |
+
for link in nav_links:
|
180 |
+
# Skip empty links or those without text
|
181 |
+
if not link.string or not link.string.strip():
|
182 |
+
continue
|
183 |
+
|
184 |
+
# Skip navigation arrows and special characters
|
185 |
+
if any(char in link.string for char in ['>', '<', '→', '←']):
|
186 |
+
continue
|
187 |
+
|
188 |
+
# Create new span for each link
|
189 |
current_span = soup.new_tag('span')
|
190 |
breadcrumb_div.append(current_span)
|
191 |
+
|
192 |
+
# Clone the link to avoid modifying original
|
193 |
+
new_link = soup.new_tag('a', href=link['href'])
|
194 |
+
new_link.string = link.string.strip()
|
195 |
+
current_span.append(new_link)
|
196 |
|
197 |
+
# Replace old navigation with new breadcrumb if we found valid navigation
|
198 |
+
if nav_container:
|
199 |
+
nav_container.replace_with(breadcrumb_div)
|
|
|
200 |
|
201 |
# Create a Flask response object with filtered content
|
202 |
response = Response(
|