Starchik1 commited on
Commit
8ded969
·
verified ·
1 Parent(s): 8b4a401

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +27 -17
main.py CHANGED
@@ -166,27 +166,37 @@ def proxy(path):
166
  breadcrumb_div = soup.new_tag('div')
167
  breadcrumb_div['class'] = 'breadcrumb'
168
 
169
- current_span = None
 
170
  for link in nav_links:
171
- # Skip links without text content or those in table cells
172
- if not link.string or link.parent.name == 'td':
173
- continue
174
-
175
- # Skip navigation arrows
176
- if '>' in link.string:
177
- continue
178
-
179
- if current_span is None:
 
 
 
 
 
 
 
 
180
  current_span = soup.new_tag('span')
181
  breadcrumb_div.append(current_span)
182
- current_span.append(link)
183
- current_span = soup.new_tag('span')
184
- breadcrumb_div.append(current_span)
 
 
185
 
186
- # Replace old navigation with new breadcrumb
187
- first_hr = soup.find('hr')
188
- if first_hr:
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(