Tutorial: consuming Twitter's real-time stream API in Python
VIA: http://arstechnica.com/open-source/guides/2010/04/tutorial-use-twitters-new-real-time-stream-api-in-python.ars/
import pycurl, json
STREAM_URL = "http://chirpstream.twitter.com/2b/user.json"
USER = "segphault"
PASS = "XXXXXXXXX"
def on_receive(data):
print data
conn = pycurl.Curl()
conn.setopt(pycurl.USERPWD, "%s:%s" % (USER, PASS))
conn.setopt(pycurl.URL, STREAM_URL)
conn.setopt(pycurl.WRITEFUNCTION, on_receive)
conn.perform()
import pycurl, json
STREAM_URL = "http://chirpstream.twitter.com/2b/user.json"
USER = "segphault"
PASS = "XXXXXXXXX"
def on_receive(data):
print data
conn = pycurl.Curl()
conn.setopt(pycurl.USERPWD, "%s:%s" % (USER, PASS))
conn.setopt(pycurl.URL, STREAM_URL)
conn.setopt(pycurl.WRITEFUNCTION, on_receive)
conn.perform()
Comments
Post a Comment