tx3bas commited on
Commit
52e0635
verified
1 Parent(s): ad567e4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+ # Funci贸n para realizar la solicitud a la API
5
+ def obtener_keywords(dominio, pais, idioma):
6
+ url = f"https://v7.authoritas.com/api/v3/visibility-explorer/ranking/keywords/{idioma}_{pais}?domains[]={dominio}&pageSize=5000"
7
+ headers = {
8
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36",
9
+ "Accept": "application/json",
10
+ "Connection": "keep-alive"
11
+ }
12
+
13
+ try:
14
+ response = requests.get(url, headers=headers, cookies={})
15
+ if response.status_code == 200:
16
+ return response.json() # Devuelve el resultado en formato JSON
17
+ else:
18
+ return {"error": f"HTTP code {response.status_code}"}
19
+ except requests.exceptions.RequestException as e:
20
+ return {"error": str(e)}
21
+
22
+ # Interfaz de Gradio
23
+ def interfaz():
24
+ with gr.Blocks() as app:
25
+ gr.Markdown("## Consulta de Keywords en Authoritas")
26
+ dominio_input = gr.Textbox(label="Dominio (ejemplo.com)")
27
+ pais_input = gr.Textbox(label="Pa铆s (ej: ES)")
28
+ idioma_input = gr.Textbox(label="Idioma (ej: es)")
29
+ output = gr.JSON(label="Resultados")
30
+
31
+ btn = gr.Button("Obtener Keywords")
32
+ btn.click(fn=obtener_keywords, inputs=[dominio_input, pais_input, idioma_input], outputs=output)
33
+
34
+ return app
35
+
36
+ # Ejecutar la aplicaci贸n
37
+ if __name__ == "__main__":
38
+ interfaz().launch()