Created
December 5, 2011 16:33
-
-
Save jperras/1434199 to your computer and use it in GitHub Desktop.
Tornado Twitter Streaming Example
This file contains hidden or 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
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 | |
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