tx3bas commited on
Commit
942af13
·
verified ·
1 Parent(s): b24bffa

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import gradio as gr
3
+ from newspaper import Article
4
+
5
+ def extract_article_info(url):
6
+ try:
7
+ article = Article(url)
8
+ article.download()
9
+ article.parse()
10
+ title = article.title
11
+ meta_description = article.meta_description
12
+ content = article.text
13
+ return title, meta_description, content
14
+ except Exception as e:
15
+ return f"Error: {str(e)}", "", ""
16
+
17
+ with gr.Interface(
18
+ fn=extract_article_info,
19
+ inputs=gr.Textbox(label="Enter URL"),
20
+ outputs=[
21
+ gr.Textbox(label="Title"),
22
+ gr.Textbox(label="Meta Description"),
23
+ gr.Textbox(label="Content", lines=15, interactive=False)
24
+ ],
25
+ title="Article Extractor",
26
+ description="Enter a URL to extract the article's title, meta description, and content."
27
+ ) as interface:
28
+ interface.launch()