tx3bas commited on
Commit
cfb1ea2
verified
1 Parent(s): 3f22a7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -48,9 +48,9 @@ def calcular_porcentajes_similaridad(serp_results, min_length):
48
  return porcentajes
49
 
50
 
51
- def generar_html_con_colores(serp_results, urls_comunes):
52
  url_color_map = {url: color_palette[i % len(color_palette)] for i, url in enumerate(urls_comunes)}
53
-
54
  html_table = "<table><tr><th>Posici贸n</th>"
55
 
56
  keywords = list(serp_results.keys())
@@ -58,15 +58,14 @@ def generar_html_con_colores(serp_results, urls_comunes):
58
  html_table += f"<th>{keyword}</th>"
59
  html_table += "</tr>"
60
 
61
- max_length = max(len(serp_results[keyword]) for keyword in keywords)
62
-
63
- for i in range(max_length):
64
  html_table += f"<tr><td>{i + 1}</td>"
65
  for keyword in keywords:
66
  if i < len(serp_results[keyword]):
67
  entry = serp_results[keyword][i]
68
  url = entry["URL"]
69
- display_url = f"<a href='{url}' target='_blank' style='color:{url_color_map[url] if url in urls_comunes else '#000'};'>{url}</a>"
70
  html_table += f"<td>{display_url}</td>"
71
  else:
72
  html_table += "<td></td>"
 
48
  return porcentajes
49
 
50
 
51
+ def generar_html_con_colores(serp_results, urls_comunes, min_length):
52
  url_color_map = {url: color_palette[i % len(color_palette)] for i, url in enumerate(urls_comunes)}
53
+
54
  html_table = "<table><tr><th>Posici贸n</th>"
55
 
56
  keywords = list(serp_results.keys())
 
58
  html_table += f"<th>{keyword}</th>"
59
  html_table += "</tr>"
60
 
61
+ # Usar min_length para limitar el n煤mero de filas en la tabla
62
+ for i in range(min_length):
 
63
  html_table += f"<tr><td>{i + 1}</td>"
64
  for keyword in keywords:
65
  if i < len(serp_results[keyword]):
66
  entry = serp_results[keyword][i]
67
  url = entry["URL"]
68
+ display_url = f"<a href='{url}' target='_blank' style='color:{url_color_map.get(url, '#000')}'>{url}</a>"
69
  html_table += f"<td>{display_url}</td>"
70
  else:
71
  html_table += "<td></td>"