File size: 1,101 Bytes
1e5a29f
b2204f0
1e5a29f
12854bd
1e5a29f
 
12854bd
 
 
b2204f0
12854bd
 
1e5a29f
 
 
 
 
 
 
 
 
 
 
 
12854bd
 
1505e07
 
 
 
1e5a29f
 
 
 
 
 
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
import requests
import streamlit as st
from bs4 import BeautifulSoup
from transformers import pipeline


@st.cache_resource
def load_model():
    return pipeline("zero-shot-classification", model="facebook/bart-large-mnli")

model = load_model()

def extract_article_text(url):
    try:
        response = requests.get(url)
        response.raise_for_status()
        soup = BeautifulSoup(response.text, 'html.parser')
        article = soup.find('div', class_='article__content')
        if article:
            return article.get_text(strip=True)
        else:
            return "Article not found."
    except Exception as e:
        return f"Error: {e}"

st.title("Tag Detection from CNN News articles")
st.write("Enter a CNN News article URL.")

news_url = st.text_input("CNN Article URL:", placeholder="Example: https://edition.cnn.com/2024/12/19/science/stonehenge-monument-early-farmers/index.html")
categories = ["Politics", "Sports", "Weather", "Culture", "Crime"]

if st.button("Get tags"):
    if news_url.strip():
        pass
    else:
        st.write("Please enter a valid news URL.")