Spaces:
Running
Running
import gradio as gr | |
import requests | |
from bs4 import BeautifulSoup | |
def summarize_website(url): | |
try: | |
response = requests.get(url) | |
soup = BeautifulSoup(response.text, "html.parser") | |
paragraphs = soup.find_all("p") | |
# Extract more content (e.g., first 10 paragraphs) | |
text = "\n\n".join([p.get_text() for p in paragraphs[:10]]) | |
# Format text as Markdown | |
markdown_summary = f"## Website Summary\n\n{text}" if text else "No content found." | |
return markdown_summary | |
except Exception as e: | |
return f"**Error:** {str(e)}" | |
iface = gr.Interface(fn=summarize_website, inputs="text", outputs=gr.Markdown(), title="Website Summarizer") | |
iface.launch() | |