Coders Packet

News Application GUI using News API in Python

By Pooja S Deshpande

In this packet, we create a simple Python GUI that fetches news items related to a topic using News API which is an easy-to-use REST API.

Overview:

In this project, we make a Python GUI for fetching news article headlines which upon clicking navigates us to that article link. We make use of an easy-to-use REST API called News API. This API fetches response in JSON format, hence we need a library in Python that helps us to handle response. This is accomplished by the "requests" library that gets downloaded along with the "newsapi-python" library.

Through the GUI, we pass the parameters of "topic-name" about which we want to fetch news items and the "number of topics" which control the number of news items to be fetched. These parameters are then appended at end of our request URL using the "requests" library that gets downloaded along with the "newsapi-python" library.

Steps to Execute:

1) Download Zip

2) For this project, we require "newsapi-python" library to be downloaded; We can simply do --> pip install newsapi-python

3) Another important requirement is to generate your own API-KEY. Go to News API page to get your API-KEY

4) Open the "NewsApp.py" file from the Zip and replace the "YOUR-API-KEY" with your own generated API-KEY

secret = "YOUR-API-KEY" #Replace this value with your API Key value

5) Now you're ready to run the code. After providing "topic name" and "number of articles", we click on the "Get News" button to fetch the required number of news items of the required topic. You can simply click on one news item, and it should take you to that respective page on a web browser.

 

(You should get output like below:)

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by Pooja S Deshpande (pooja450)

Download packets of source code on Coders Packet