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

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +21 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from newspaper import Article
3
+
4
+ def extraer_texto(url):
5
+ try:
6
+ articulo = Article(url, language='es')
7
+ articulo.download()
8
+ articulo.parse()
9
+ return articulo.text
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()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ newspaper3k
3
+ lxml_html_clean