-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathmain.py
53 lines (35 loc) · 1.2 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import streamlit as st
import newspaper
import nltk
nltk.download('punkt')
# st.markdown('<style> .css-1v0mbdj {margin:0 auto; width:50%; </style>', unsafe_allow_html=True)
st.title('Article Summarizer')
url = st.text_input('', placeholder='Paste the URL of the article amd press Enter')
if url:
try:
article = newspaper.Article(url)
article.download()
# article.html
article.parse()
img = article.top_image
st.image(img)
title = article.title
st.subheader(title)
authors = article.authors
st.text(','.join(authors))
article.nlp()
keywords = article.keywords
st.subheader('Keywords:')
st.write(', '.join(keywords))
tab1, tab2= st.tabs(["Full Text", "Summary"])
with tab1:
txt = article.text
txt = txt.replace('Advertisement', '')
st.write(txt)
with tab2:
st.subheader('Summary')
summary = article.summary
summary = summary.replace('Advertisement', '')
st.write(summary)
except:
st.error('Sorry something went wrong')