Spaces:
Sleeping
Sleeping
Download app.py from Teststrelema/News_Scraper: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/Teststrelema/News_Scraper/resolve/main/app.py
- Command line
-
hf download hf://spaces/Teststrelema/News_Scraper/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Teststrelema/News_Scraper/resolve/main/app.py
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") |