File size: 742 Bytes
66a4d52
 
 
 
 
 
 
 
 
c0d7d7d
 
 
 
 
 
 
 
66a4d52
c0d7d7d
66a4d52
c0d7d7d
66a4d52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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()