Skip to content

Instantly share code, notes, and snippets.

@bsmithgall
Created February 2, 2014 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bsmithgall/8772438 to your computer and use it in GitHub Desktop.
Save bsmithgall/8772438 to your computer and use it in GitHub Desktop.
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