【发布时间】:2014-12-29 08:18:14
【问题描述】:
我正在使用 Tweepy 库的 Python 代码来检索特定主题标签的 Twitter 数据,但问题是我需要检索特定时期,例如,从 2013 年 6 月 30 日到 2013 年 12 月 30 日。我该怎么做?
#imports
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
#setting up the keys
consumer_key = '……………….'
consumer_secret = '……………..'
access_token = '……………….'
access_secret = '……………..'
class TweetListener(StreamListener):
# A listener handles tweets are the received from the stream.
#This is a basic listener that just prints received tweets to standard output
def on_data(self, data):
print (data)
return True
def on_error(self, status):
print (status)
#printing all the tweets to the standard output
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
stream = Stream(auth, TweetListener())
t = u"#سوريا"
stream.filter(track=[t])
【问题讨论】:
-
您无法获取该数据;参见例如stackoverflow.com/a/1733360/3001761
-
但我连续两天运行代码,检索数据。所有这些元数据只需三周?
-
@Hana 你能解决这个问题吗?
-
系统仍在检索数据,我不想中断它。我正在等待系统完成检索数据。但是如果您想自己尝试,有人提交了另一个答案,您可以查看!