Spaces:
Runtime error
Runtime error
Alberto Carmona
commited on
Commit
·
92bb964
1
Parent(s):
428a5aa
Use the function to extract the text
Browse files- app.py +2 -1
- functions.py +4 -1
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
def update(name='default text'):
|
|
@@ -16,7 +17,7 @@ with gr.Blocks() as demo:
|
|
| 16 |
show_label=False)
|
| 17 |
btn_extract_text = gr.Button("Extraer texto")
|
| 18 |
out_url_text = gr.Textbox(label="Texto extraído")
|
| 19 |
-
btn_extract_text.click(fn=
|
| 20 |
|
| 21 |
# Summary section
|
| 22 |
gr.Markdown("## Elaborar resumen")
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from functions import extract_text
|
| 3 |
|
| 4 |
|
| 5 |
def update(name='default text'):
|
|
|
|
| 17 |
show_label=False)
|
| 18 |
btn_extract_text = gr.Button("Extraer texto")
|
| 19 |
out_url_text = gr.Textbox(label="Texto extraído")
|
| 20 |
+
btn_extract_text.click(fn=extract_text, inputs=inp_url, outputs=out_url_text)
|
| 21 |
|
| 22 |
# Summary section
|
| 23 |
gr.Markdown("## Elaborar resumen")
|
functions.py
CHANGED
|
@@ -1,7 +1,10 @@
|
|
| 1 |
import requests
|
| 2 |
from bs4 import BeautifulSoup
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
| 5 |
response = requests.get(url)
|
| 6 |
soup = BeautifulSoup(response.text, "html.parser")
|
| 7 |
text = '\n\n'.join(map(lambda p: p.text, soup.find_all('p')))
|
|
|
|
| 1 |
import requests
|
| 2 |
from bs4 import BeautifulSoup
|
| 3 |
|
| 4 |
+
|
| 5 |
+
def extract_text(url: str):
|
| 6 |
+
if url is None or url.strip() == '':
|
| 7 |
+
return ''
|
| 8 |
response = requests.get(url)
|
| 9 |
soup = BeautifulSoup(response.text, "html.parser")
|
| 10 |
text = '\n\n'.join(map(lambda p: p.text, soup.find_all('p')))
|