Skip to content

Instantly share code, notes, and snippets.

@jkarakas
Forked from nonsleepr/Makefile
Created November 12, 2017 09:16
Show Gist options
  • Save jkarakas/0a104002479b7017c6db85d01e23b06c to your computer and use it in GitHub Desktop.
Save jkarakas/0a104002479b7017c6db85d01e23b06c 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