tx3bas commited on
Commit
126f58f
verified
1 Parent(s): 2f704d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -16
app.py CHANGED
@@ -1,19 +1,9 @@
1
  import gradio as gr
2
- import pandas as pd
3
  import requests
4
  from bs4 import BeautifulSoup
5
  import re
6
- from IPython.core.display import display, HTML
7
  from urllib.parse import urlparse
8
 
9
- def limpiar_dominio(dominio):
10
- dominio_limpio = re.sub(r"https?://", "", dominio)
11
- dominio_limpio = re.sub(r"^www\.", "", dominio_limpio)
12
- dominio_limpio = dominio_limpio.split(".")[-2] if len(dominio_limpio.split(".")) > 1 else dominio_limpio
13
- dominio_limpio = re.sub(r"\.[a-zA-Z]{2,}$", "", dominio_limpio)
14
- dominio_limpio = dominio_limpio.capitalize()
15
- return dominio_limpio
16
-
17
  def buscar_google(query, dominio, hl='es', num_results=100):
18
  all_results = []
19
  posiciones_dominio = []
@@ -57,18 +47,35 @@ def buscar_google(query, dominio, hl='es', num_results=100):
57
 
58
  # Construcci贸n del mensaje y la tabla HTML
59
  mensaje = ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  if len(posiciones_dominio) > 1 and 1 in posiciones_dominio:
61
- mensaje = f"Parasitaci贸n SEO: {url_objetivo} se encuentra en las posiciones {posiciones_dominio} 馃"
62
  elif len(posiciones_dominio) > 1:
63
- mensaje = f"Canibalizaci贸n: {url_objetivo} se encuentra en las posiciones {posiciones_dominio} 馃槙"
64
  elif len(posiciones_dominio) == 1 and len(posiciones_dominio_exacto) == 0:
65
- mensaje = f"Canibalizaci贸n: URL diferente del dominio en la posici贸n {posiciones_dominio[0]} 馃槙"
66
  elif len(posiciones_dominio) == 1:
67
- mensaje = f"Sin canibalizaci贸n: {url_objetivo} se encuentra en la posici贸n {posiciones_dominio[0]} 馃槙"
68
  else:
69
- mensaje = f"{url_objetivo} no se encuentra en el top 100 馃槙"
70
 
71
- html_output = f"<div><b>{mensaje}</b></div>"
 
72
  html_output += "<details style='padding: 10px; background: #f3f3f3; border: solid 0; border-radius: 8px; margin-top: 10px;'><summary>Ver Resultados</summary>"
73
  html_output += table_html
74
  html_output += "</details>"
 
1
  import gradio as gr
 
2
  import requests
3
  from bs4 import BeautifulSoup
4
  import re
 
5
  from urllib.parse import urlparse
6
 
 
 
 
 
 
 
 
 
7
  def buscar_google(query, dominio, hl='es', num_results=100):
8
  all_results = []
9
  posiciones_dominio = []
 
47
 
48
  # Construcci贸n del mensaje y la tabla HTML
49
  mensaje = ""
50
+ emoji = ""
51
+ if posiciones_dominio:
52
+ first_position = posiciones_dominio[0]
53
+ if first_position == 1:
54
+ emoji = "馃"
55
+ elif first_position <= 3:
56
+ emoji = "馃槑"
57
+ elif first_position <= 5:
58
+ emoji = "馃槅"
59
+ elif first_position <= 10:
60
+ emoji = "馃檪"
61
+ elif first_position <= 100:
62
+ emoji = "馃槓"
63
+ else:
64
+ emoji = "馃槶"
65
+
66
  if len(posiciones_dominio) > 1 and 1 in posiciones_dominio:
67
+ mensaje = f"Parasitaci贸n SEO: {url_objetivo} se encuentra en las posiciones {posiciones_dominio}"
68
  elif len(posiciones_dominio) > 1:
69
+ mensaje = f"Canibalizaci贸n: {url_objetivo} se encuentra en las posiciones {posiciones_dominio}"
70
  elif len(posiciones_dominio) == 1 and len(posiciones_dominio_exacto) == 0:
71
+ mensaje = f"Canibalizaci贸n: URL diferente del dominio en la posici贸n {posiciones_dominio[0]}"
72
  elif len(posiciones_dominio) == 1:
73
+ mensaje = f"Sin canibalizaci贸n: {url_objetivo} se encuentra en la posici贸n {posiciones_dominio[0]}"
74
  else:
75
+ mensaje = f"{url_objetivo} no se encuentra en el top 100"
76
 
77
+ mensaje_completo = f"Posici贸n: {emoji}<br>{mensaje}"
78
+ html_output = f"<div><b>{mensaje_completo}</b></div>"
79
  html_output += "<details style='padding: 10px; background: #f3f3f3; border: solid 0; border-radius: 8px; margin-top: 10px;'><summary>Ver Resultados</summary>"
80
  html_output += table_html
81
  html_output += "</details>"