16.HarRozNews.py

 # To Show the TOP 5 news headlines and their author's name

import requests
import json

#to just fetch the news form the newsAPI websites as it is
r = requests.get('https://newsapi.org/v2/top-headlines?country=in&apiKey=b0e1da350f2e46649f9865d403b8b9d3')
# print(r.content)

#to make it readable json is used
news = json.loads(r.content)
# print(news)

#to print top TOP 5 news
for i in range(0, 5):
print("\n" + "News", i+1, ":", news['articles'][i]['title'], "\n", news['articles'][i]['description'])










Comments

Popular posts from this blog

3.FaulyCalculator.py

11.Snake Water Gun Game.py

15.PyStopWatch.py