[英]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. 我想用python和tweepy流式传输自己的Twitter时间轴,并在下面使用代码,但它只向我打印一些数字,我也将打印时间轴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')
If you take a look at the documentation it says: 如果您看一下文档,它会显示:
The
on_data
method of Tweepy's StreamListener conveniently passes data from statuses to theon_status
method.Tweepy的StreamListener的
on_data
方法可以方便地将数据从状态传递到on_status
方法。
The numbers you are seeing are the object IDs of the Tweets. 您看到的数字是Tweets的对象ID。 You will need to do something like:
您将需要执行以下操作:
def on_status(self, status):
print(status.text)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.