Skip to content

Instantly share code, notes, and snippets.

@munk
Created November 15, 2014 15:27
Show Gist options
  • Save munk/22d8d344293c8889c3e1 to your computer and use it in GitHub Desktop.
Save munk/22d8d344293c8889c3e1 to your computer and use it in GitHub Desktop.
import json
import httplib
import pymongo
from time import sleep
url = 'http://citibikenyc.com/stations/json'
connection = pymongo.Connection()
db = connection['citibike']
collection = db['station_status']
citibike_conn = httplib.HTTPConnection('citibikenyc.com')
for i in range(0, 24*60):
citibike_conn.request('GET', '/stations/json')
response = citibike_conn.getresponse()
data = json.loads(response.read())
collection.insert(data)
sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment