Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
|
@@ -15,16 +15,26 @@ with gr.Blocks() as demo:
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
| 19 |
btn_extraer = gr.Button("Extraer texto")
|
| 20 |
|
| 21 |
-
#
|
| 22 |
gr.HTML("""
|
| 23 |
-
<button
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
""")
|
| 27 |
|
| 28 |
-
btn_extraer.click(fn=extraer_texto, inputs=url_input, outputs=texto_output)
|
| 29 |
|
| 30 |
demo.launch()
|
|
|
|
| 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 |
+
|
| 19 |
+
# Añadimos un id al textbox del texto extraído para que sea fácil referenciarlo
|
| 20 |
+
texto_output = gr.Textbox(label="Texto extraído", lines=20, interactive=False, elem_id="texto_extraido")
|
| 21 |
+
|
| 22 |
btn_extraer = gr.Button("Extraer texto")
|
| 23 |
|
| 24 |
+
# Botón HTML personalizado que usa el id para copiar el texto específico
|
| 25 |
gr.HTML("""
|
| 26 |
+
<button style="margin-top:10px;" onclick="
|
| 27 |
+
const txt = document.querySelector('#texto_extraido textarea');
|
| 28 |
+
if (txt) {
|
| 29 |
+
navigator.clipboard.writeText(txt.value).then(() => {
|
| 30 |
+
alert('Texto copiado al portapapeles ✅');
|
| 31 |
+
});
|
| 32 |
+
} else {
|
| 33 |
+
alert('No se encontró el campo de texto para copiar.');
|
| 34 |
+
}
|
| 35 |
+
">📋 Copiar texto</button>
|
| 36 |
""")
|
| 37 |
|
| 38 |
+
btn_extraer.click(fn=extraer_texto, inputs=[url_input], outputs=[texto_output])
|
| 39 |
|
| 40 |
demo.launch()
|