Created
November 15, 2014 15:27
-
-
Save munk/22d8d344293c8889c3e1 to your computer and use it in GitHub Desktop.
This file contains 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 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