【发布时间】:2014-01-20 13:44:51
【问题描述】:
我想查看所有带有特定主题标签的推文。我写的代码是这样的:
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
ckey = 'xxx'
csecret = 'xxx'
atoken = 'xxx'
asecret = 'xxx'
class listener(StreamListener):
def on_status(self, status):
print 'Tweet text: ' + status.text
for hashtag in status.entries['hashtags']:
print hashtag['text']
return True
def on_data(self, data):
print data
return True
def on_error(self, status):
print status
auth = OAuthHandler(ckey, csecret)
auth.set_access_token(atoken, asecret)
twitterStream = Stream(auth, listener())
twitterStream.filter(follow=[23], track=["#django"])
关注我的一些朋友,跟踪 - 想要查看带有主题标签的消息。
在我写的一个测试帐户上,不断关注想要查看的主题标签。当我运行程序时,python 崩溃了。
我做错了什么?
感谢您的帮助。
【问题讨论】:
-
Python 崩溃时得到的回溯是什么?
-
我长时间没有得到任何回溯程序执行,也不能被Ctrl + C打断。
标签: python twitter stream hashtag tweepy