Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
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 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 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()
|