Skip to content

Instantly share code, notes, and snippets.

@jperras
Created December 5, 2011 16:33
Show Gist options
  • Save jperras/1434199 to your computer and use it in GitHub Desktop.
Save jperras/1434199 to your computer and use it in GitHub Desktop.
Tornado Twitter Streaming Example
from tornado.httpclient import HTTPClient, HTTPRequest
import simplejson
def handle_tweet_stream(response):
try:
# Print the parsed twitter stream.
print simplejson.loads(response)
except ValueError:
return
print
if __name__ == '__main__':
req = HTTPRequest(
"http://stream.twitter.com/1/statuses/filter.json",
body='track=google',
method = "POST",
auth_username = "username",
auth_password = "xxxxxxx",
streaming_callback=handle_tweet_stream)
client = HTTPClient()
client.fetch(req)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment