1. Brendan Howell
  2. PyCessing

Source

PyCessing / pycessing / data / examples / twitter-search.cess

#pull status updates from the twitter API

import json
import urllib2


mytext = ScreenText(size=15)
results = {}
searchterm = "hats"
twitterapi = "http://search.twitter.com/search.json?rpp=5&result_type=mixed&q="

def setup():
    global results
    
    pycessing.noLoop = True    
    pycessing.size(800,600)
    
    request = urllib2.urlopen(twitterapi + searchterm)    
    results = json.load(request)
   
    
def draw():
    ypos = 10
    for result in results["results"]:
        mytext.setText(result["text"].strip())
        print result["text"]
        mytext.draw(10,ypos)
        ypos += 30