#!/usr/bin/python # -*- coding: utf-8 -*- import sys import json import tweepy import re # Account consumer_key= ' ' consumer_secret= ' ' access_token= ' ' access_token_secret= ' ' class Listener(tweepy.streaming.StreamListener): def on_data(self, data): if data.startswith("{"): tweet = json.loads(data) if 'text' in tweet: user = tweet['user'] text = re.sub(r'\n',r' ',tweet['text'].encode('utf-8')