Skip to content

Instantly share code, notes, and snippets.

@nonsleepr
Created March 27, 2015 15:40
Show Gist options
  • Save nonsleepr/5f18d9b82b069948e2df to your computer and use it in GitHub Desktop.
Save nonsleepr/5f18d9b82b069948e2df to your computer and use it in GitHub Desktop.
Makefile to download Kaggle's datasets
# Requires presence of credentials.txt file containing login/password in the following format:
# UserName=my_username&Password=my_password
COMPETITION=diabetic-retinopathy-detection
all: download_files
session.cookie: credentials.txt
curl -o /dev/null -c session.cookie https://www.kaggle.com/account/login
curl -o /dev/null -c session.cookie -b session.cookie -L -d @credentials.txt https://www.kaggle.com/account/login
files.txt: session.cookie
curl -c session.cookie -b session.cookie -L http://www.kaggle.com/c/$(COMPETITION)/data | \
grep -o \"[^\"]*\/download[^\"]*\" | sed -e 's/"//g' -e 's/^/http:\/\/www.kaggle.com/' > files.txt
download_files: files.txt session.cookie
mkdir -p files
cd files && xargs -n 1 curl -b ../session.cookie -L -O < ../files.txt
.PHONY: clean
clean:
rm session.cookie files.txt files/*.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment