Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#This module was written by Rahul Verma and edited slightly for GUI integration by Humza Shahid.
import requests
# https://newsapi.org/
def mtvAPI():
mtv_news = requests.get("https://newsapi.org/v2/top-headlines?sources=mtv-news&apiKey=01dff295c83e4b2da79345b4cb2e1175").json()
json_status = mtv_news['status']
articleList = []
descriptionList = []
urlList = []
for x in range(0, 5):
articleList.append(mtv_news['articles'][x]['title'].upper())
descriptionList.append(mtv_news['articles'][x]['description'])
urlList.append((mtv_news['articles'][x]['url']))
return articleList, descriptionList, urlList
def lad_bibleAPI():
lad_bible = requests.get("https://newsapi.org/v2/top-headlines?sources=the-lad-bible&apiKey=01dff295c83e4b2da79345b4cb2e1175").json()
json_status = lad_bible['status']
articleList = []
descriptionList = []
urlList = []
for x in range(0,5):
articleList.append(lad_bible['articles'][x]['title'].upper())
descriptionList.append(lad_bible['articles'][x]['description'])
urlList.append(lad_bible['articles'][x]['url'])
return articleList, descriptionList, urlList
def buzzfeedAPI():
buzzfeed = requests.get("https://newsapi.org/v2/top-headlines?sources=buzzfeed&apiKey=01dff295c83e4b2da79345b4cb2e1175").json()
json_status = buzzfeed['status']
articleList = []
descriptionList = []
urlList = []
for x in range(0,5):
articleList.append(buzzfeed['articles'][x]['title'].upper())
descriptionList.append(buzzfeed['articles'][x]['description'])
urlList.append(buzzfeed['articles'][x]['url'])
return articleList, descriptionList, urlList
def ent_menu(menu):
if menu == "1":
mtvAPI()
elif menu == "2":
lad_bibleAPI()
elif menu == "3":
buzzfeedAPI()
else:
sports_menu()