Created
October 6, 2019 10:15
-
-
Save Doarakko/8c920d507a8c00e5be0caac65a8c0af8 to your computer and use it in GitHub Desktop.
Print kaggle competitions information using kaggle api.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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