Created
February 2, 2014 18:15
-
-
Save bsmithgall/8772438 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 datetime | |
import requests | |
import json | |
BASE_URL = 'http://charts.spotify.com/api/charts/most_streamed/global/%s' | |
first_date = datetime.date(2013,04,28) | |
data = {} | |
for i in xrange(50): | |
req_date = datetime.datetime.strftime(first_date + datetime.timedelta(i*7), '%Y-%m-%d') | |
try: | |
data[req_date] = requests.get(BASE_URL % (req_date)).json() | |
except: | |
break | |
print json.dumps(data) | |
# to run, just pipe to a file (for example) | |
# python this_file.py | tee > output.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment