Skip to content

Instantly share code, notes, and snippets.

@jarobins
Created August 25, 2013 12:21
Show Gist options
  • Save jarobins/6333575 to your computer and use it in GitHub Desktop.
Save jarobins/6333575 to your computer and use it in GitHub Desktop.
Twitter Stream
import json
import requests
from requests_oauthlib import OAuth1
consumer_key='key'
consumer_secret='secret'
access_token_key='t_key'
access_token_secret='t_secret'
auth = OAuth1(consumer_key, consumer_secret,
access_token_key, access_token_secret)
r = requests.get('https://stream.twitter.com/1.1/statuses/sample.json',
stream=True, auth=auth)
for line in r.iter_lines():
# filter out keep-alive new lines
if line:
print json.loads(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment