|
|
|
|
|
import gradio as gr |
|
|
from newspaper import Article |
|
|
|
|
|
def extract_article_info(url): |
|
|
try: |
|
|
article = Article(url) |
|
|
article.download() |
|
|
article.parse() |
|
|
title = article.title |
|
|
meta_description = article.meta_description |
|
|
content = article.text |
|
|
return title, meta_description, content |
|
|
except Exception as e: |
|
|
return f"Error: {str(e)}", "", "" |
|
|
|
|
|
with gr.Interface( |
|
|
fn=extract_article_info, |
|
|
inputs=gr.Textbox(label="Enter URL"), |
|
|
outputs=[ |
|
|
gr.Textbox(label="Title"), |
|
|
gr.Textbox(label="Meta Description"), |
|
|
gr.Textbox(label="Content", lines=15, interactive=False) |
|
|
], |
|
|
title="Article Extractor", |
|
|
description="Enter a URL to extract the article's title, meta description, and content." |
|
|
) as interface: |
|
|
interface.launch() |
|
|
|