File size: 1,069 Bytes
c1eea52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import tempfile
import os

from scraper import scrape_news

st.set_page_config(
    page_title="AI News Scraper",
    layout="centered"
)

st.title("📰 Multi-Language News Scraper")

st.write("Upload Excel file with a column named: Link")

uploaded_file = st.file_uploader(
    "Upload Excel File",
    type=["xlsx"]
)

if st.button("Start Scraping"):

    if uploaded_file is not None:

        temp_dir = tempfile.mkdtemp()

        input_path = os.path.join(
            temp_dir,
            uploaded_file.name
        )

        with open(input_path, "wb") as f:
            f.write(uploaded_file.read())

        with st.spinner("Scraping articles..."):

            txt_output = scrape_news(input_path)

        st.success("Scraping completed ✅")

        with open(txt_output, "rb") as f:

            st.download_button(
                "Download TXT File",
                data=f,
                file_name="scraped_news.txt",
                mime="text/plain"
            )

    else:
        st.warning("Please upload Excel file")