import tweepyfrom tweepy.streaming import StreamListener,Streamclass Listener (StreamListener): def on_status(self,status): print '-' * 20 print status.text returndef get_tweets(request): # if request.is_AJAX(): # All keys and secrets are declared here,but were removed for security reasons. auth = tweepy.OAuthHandler(CONSUMER_KEY,CONSUMER_SECRET) auth.set_access_token(ACCESS_KEY,ACCESS_SECRET) API = tweepy.API(auth) Listener = Listener() stream = Stream(auth,Listener) stream.filter(follow=("14739093",),count=-5)
我也尝试了以下内容,看看它返回了什么.
>>> something = stream.filter(follow=("14739093",count=-5)>>> print somethingNone
谢谢你的帮助!
解决方法 Stream.filter总是返回None,它的工作就是将数据传递给StreamListener.你的问题是Twitter只允许某些“角色”的count参数.
Firehose,links,Birddog and Shadow clIEnts interested in capturing all statuses should maintain a current estimate of the number of statuses received per second and note the time that the last status was received. Upon a reconnect,the clIEnt can then estimate the appropriate backlog to request. Note that the count parameter is not allowed elsewhere,including track,sample and on the default access role.
这是您尝试使用count参数时出现413错误的原因 – 您处于“默认访问”角色.
总结以上是内存溢出为你收集整理的如何在tweepy的流API中使用’count’参数?全部内容,希望文章能够帮你解决如何在tweepy的流API中使用’count’参数?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)