Skip to content

Instantly share code, notes, and snippets.

@Doarakko
Created October 6, 2019 10:15
Show Gist options
  • Save Doarakko/8c920d507a8c00e5be0caac65a8c0af8 to your computer and use it in GitHub Desktop.
Save Doarakko/8c920d507a8c00e5be0caac65a8c0af8 to your computer and use it in GitHub Desktop.
Print kaggle competitions information using kaggle api.
import time
from kaggle import KaggleApi
def new_kaggle_api():
api = KaggleApi()
api.authenticate()
return api
def print_competition_keys():
api = new_kaggle_api()
competitions = api.competitions_list()
for key in dir(competitions[0]):
print('{}: {}'.format(key, getattr(competitions[0], key)))
def print_competitions_info(page=1):
api = new_kaggle_api()
competitions = api.competitions_list(sort_by='latestDeadline', page=page)
time.sleep(1)
for competition in competitions:
# if you want to get more information, run print_competition_keys
title = getattr(competition, 'title')
print('{}'.format(title))
if competitions != []:
print_competitions_info(page=page+1)
if __name__ == "__main__":
# print_competition_keys()
print_competitions_info()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment