user3480650
user3480650

Reputation: 19

twitter timeline streaming with tweepy

i want to stream my own twitter timeline with python and tweepy and use code in below but it just print me some numbers and i dosent print my timeline twitts. Can you help me?

import tweepy
from tweepy import Stream
from tweepy.streaming import StreamListener

consumer_key = 'abc'
consumer_secret = 'abc'
access_token = 'abc'
access_secret = 'abc'

auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)

api = tweepy.API(auth)
class listener(StreamListener):

    def on_data(self, data):
        print (data)
        return True
    def on_error(self, status):
        print (status)

twitterStream = Stream(auth, listener()) 
twitterStream.userstream(encoding='utf8')

Upvotes: 1

Views: 930

Answers (1)

Terence Eden
Terence Eden

Reputation: 14334

If you take a look at the documentation it says:

The on_data method of Tweepy’s StreamListener conveniently passes data from statuses to the on_status method.

The numbers you are seeing are the object IDs of the Tweets. You will need to do something like:

def on_status(self, status):
    print(status.text)

Upvotes: 2

Related Questions