Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
from bs4 import BeautifulSoup
|
4 |
+
|
5 |
+
def summarize_website(url):
|
6 |
+
try:
|
7 |
+
response = requests.get(url)
|
8 |
+
soup = BeautifulSoup(response.text, "html.parser")
|
9 |
+
paragraphs = soup.find_all("p")
|
10 |
+
text = " ".join([p.get_text() for p in paragraphs[:5]])
|
11 |
+
return text if text else "No content found."
|
12 |
+
except Exception as e:
|
13 |
+
return f"Error: {str(e)}"
|
14 |
+
|
15 |
+
iface = gr.Interface(fn=summarize_website, inputs="text", outputs="text", title="Website Summarizer")
|
16 |
+
iface.launch()
|