News_Scraper / app.py
Teststrelema's picture
Create app.py
c1eea52 verified
Raw History Blame Contribute Delete
1.07 kB
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")