Consuming the news from traditional to new ways of socially acceptable reels form import time import schedule import requests from bs4 import BeautifulSoup from datetime import datetime
def fetch_news(): url = 'https://news.ycombinator.com/' # Example news site response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') headlines = soup.find_all('a', class_='storylink')
print(f"News Update at {datetime.now()}:")
for i, headline in enumerate(headlines[:10], 1):
print(f"{i}. {headline.text}")
schedule.every().day.at("09:00").do(fetch_news) schedule.every().day.at("12:00").do(fetch_news) schedule.every().day.at("18:00").do(fetch_news)
print("Sreela News Scheduler Started. Press Ctrl+C to exit.")
while True: schedule.run_pending() time.sleep(1)
Sreela is a Python-based scheduled news delivery system that fetches and displays the latest headlines from a specified news website at scheduled times. This eliminates the hassle of manually checking online news sites, providing you with timely news updates directly in your terminal.
- Scheduled News Fetching: Automatically fetches news at specified times.
- Customizable: Easily change the news source and schedule times.
- Lightweight: Minimal dependencies and easy to set up.
-
Clone the Repository:
git clone https://github.com/yourusername/sreela.git cd sreela
-
Install Dependencies: Sreela requires
requests
andbeautifulsoup4
for fetching and parsing news. Install them using pip:pip install requests beautifulsoup4
-
Run the Script:
python sreela.py
-
The script will fetch news headlines at 9:00 AM, 12:00 PM, and 6:00 PM every day. You can customize these times in the
sreela.py
file.
-
Change News Source: Modify the
url
variable in thefetch_news
function to change the news source.url = 'https://news.ycombinator.com/' # Example news site
-
Change Schedule Times: Update the
schedule.every().day.at("HH:MM").do(fetch_news)
lines to your desired times.
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Happy news reading with Sreela!