Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,10 +7,16 @@ def summarize_website(url):
|
|
7 |
response = requests.get(url)
|
8 |
soup = BeautifulSoup(response.text, "html.parser")
|
9 |
paragraphs = soup.find_all("p")
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
except Exception as e:
|
13 |
-
return f"Error
|
14 |
|
15 |
-
iface = gr.Interface(fn=summarize_website, inputs="text", outputs=
|
16 |
iface.launch()
|
|
|
7 |
response = requests.get(url)
|
8 |
soup = BeautifulSoup(response.text, "html.parser")
|
9 |
paragraphs = soup.find_all("p")
|
10 |
+
|
11 |
+
# Extract more content (e.g., first 10 paragraphs)
|
12 |
+
text = "\n\n".join([p.get_text() for p in paragraphs[:10]])
|
13 |
+
|
14 |
+
# Format text as Markdown
|
15 |
+
markdown_summary = f"## Website Summary\n\n{text}" if text else "No content found."
|
16 |
+
|
17 |
+
return markdown_summary
|
18 |
except Exception as e:
|
19 |
+
return f"**Error:** {str(e)}"
|
20 |
|
21 |
+
iface = gr.Interface(fn=summarize_website, inputs="text", outputs=gr.Markdown(), title="Website Summarizer")
|
22 |
iface.launch()
|