Guest User

Get last data from SCK

a guest
Jun 19th, 2013
106
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pycurl, cStringIO, json
  2.  
  3. device = 139
  4. buf = cStringIO.StringIO()
  5.  
  6. c = pycurl.Curl()
  7. c.setopt(c.URL, 'http://data.smartcitizen.me/testjson?device={0}'.format(device))
  8. c.setopt(c.WRITEFUNCTION, buf.write)
  9. c.perform()
  10.  
  11. resStr = buf.getvalue()
  12. buf.close()
  13.  
  14. obj = json.loads(resStr)
  15. last = obj[-1]
  16.  
  17. for data in last:
  18.     print "{0}: {1}".format(data, last[data])
RAW Paste Data