Python To read the news
Hello Guys, in this blog we will use Python to read the news. Before this, the concepts of APIs, JSON, Python Libraries should be clear.
We are going to use 'newsdataapi' library of Python. The newsdataapi
is the official Python client library for the Newsdata.io API. Its primary purpose is to simplify the process of accessing global news data directly from Newsdata.io, allowing developers to integrate news content into their applications without having to manually construct HTTP requests. It acts as a wrapper around the API, handling the complexities of authentication, request parameters, and response parsing.
So Lets Start.
Making Python to read the online news
Step 1: Get your API key
- Sign Up : Go to the Newsdata.io website and create a free account. The free plan typically offers a limited number of credits per day (e.g., 200 credits).
- Get the Key: Once you've created and verified your account, your unique API key will be available on your dashboard. Copy this key, as you will need it for every API call.
In this script:
You initialize the
NewsDataApiClient
with your unique API key.You call the
news_api()
method, which corresponds to one of their API endpoints. You can pass various parameters, such asq
(for a search query) orlanguage
.The API returns a JSON object, which you can then access like a Python dictionary to get the article data.
We can further develop more to like GUI version of it by using tkinter, kivy , request etc. We can also use this in our web development project of flask, django python.
Comments
Post a Comment