djzero2 commited on
Commit
ca9bf74
·
verified ·
1 Parent(s): e88b43f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -7
app.py CHANGED
@@ -10,12 +10,29 @@ def extraer_texto(url):
10
  except Exception as e:
11
  return f"[Error al extraer texto]: {str(e)}"
12
 
13
- demo = gr.Interface(
14
- fn=extraer_texto,
15
- inputs=gr.Textbox(label="Pega la URL de la noticia"),
16
- outputs="text",
17
- title="Extractor de Texto de Noticias",
18
- description="Extrae el texto plano de una noticia desde su enlace. Solo pega el enlace."
19
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  demo.launch()
 
10
  except Exception as e:
11
  return f"[Error al extraer texto]: {str(e)}"
12
 
13
+ with gr.Blocks() as demo:
14
+ gr.Markdown("## Extractor de Texto de Noticias 📰")
15
+ gr.Markdown("Pega el enlace de una noticia para extraer su contenido limpio.")
16
+
17
+ url_input = gr.Textbox(label="URL de la noticia", placeholder="https://...")
18
+ texto_output = gr.Textbox(label="Texto extraído", lines=20, interactive=False)
19
+
20
+ btn_extraer = gr.Button("Extraer texto")
21
+ btn_copiar = gr.Button("📋 Copiar texto")
22
+
23
+ btn_extraer.click(fn=extraer_texto, inputs=url_input, outputs=texto_output)
24
+
25
+ btn_copiar.click(
26
+ None,
27
+ [],
28
+ [],
29
+ _js="""
30
+ () => {
31
+ const text = document.querySelector('textarea').value;
32
+ navigator.clipboard.writeText(text);
33
+ alert('Texto copiado al portapapeles ✅');
34
+ }
35
+ """
36
+ )
37
 
38
  demo.launch()