Read latest news using newsapi | Python
In this article, we will learn how to create a Python script to read the latest news. We will fetch news from news API and after that, we will read news using pyttsx3.
Modules required :
pyttsx3 - pip install pyttsx3 requests - pip install requests
To get a API for news we will use newsapi.org. we will create account and take API key by clicking on get API button.
Step #1: Import modules needed
Step #2: Setting up URL with API key, place your API key here.
Step #3: Setting an engine for pyttsx3 for reading news.
Step #4: Setting up properties of our engine, means reading rate, volume, and sound of a voice.
Step #5: Trying to send request to get news. Here, engine.say() function is used to read news.
Now, everything is ready build a loop to read new articles.
Below is the complete Python implementation :
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course