Skip to content

Instantly share code, notes, and snippets.

@erickgnavar
Last active August 29, 2015 14:21
Show Gist options
  • Save erickgnavar/15404c12635b3aab8a5c to your computer and use it in GitHub Desktop.
Save erickgnavar/15404c12635b3aab8a5c to your computer and use it in GitHub Desktop.
Twitter mongo example
# coding: utf-8
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACESS_TOKEN = ''
ACCESS_TOKEN_SECRET = ''
from twython import TwythonStreamer
from pymongo import MongoClient
db = MongoClient('localhost').twitter
class MyStreamer(TwythonStreamer):
def on_success(self, data):
db.my_db.insert(data)
def on_error(self, status_code, data):
print status_code
stream = MyStreamer(CONSUMER_KEY, CONSUMER_SECRET,
ACESS_TOKEN, ACCESS_TOKEN_SECRET)
stream.statuses.filter(track='#hashtag')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment