[英]twitter streaming API using python 3
Is there any method to fetch tweets over a specific span of time,using twitter streaming API,in python 3? 在python 3中,是否有任何方法可以使用Twitter流API在特定时间范围内获取推文? I am working on a project to fetch tweets that are dated from April 2017 to June 2017.But all I get is the real time tweets.The following is my code in python 3.6:
我正在一个项目中提取日期为2017年4月至2017年6月的tweet,但是我得到的只是实时tweets。以下是我在python 3.6中的代码:
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
access_token = "####"
access_token_secret = "###"
consumer_key = "###"
consumer_secret = "####"
def on_data(self, data):
print (data)
return True
def on_error(self, status):
print (status)
if __name__ == '__main__':
l = StdOutListener()
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
stream = Stream(auth, l)
stream.filter(track=['earthquake','Mexico','2017'])
What changes shall I do in the above code? 我应该对以上代码进行哪些更改?
Twitter's Streaming API returns only real-time tweets. Twitter的Streaming API 仅返回实时推文。 So, the answer is no.
因此,答案是否定的。 Use Twitter's REST API -- specifically, the search/tweets endpoint -- to get historical tweets.
使用Twitter的REST API(特别是搜索/推文端点)获取历史推文。 But, that gets you only the last week's worth of tweets.
但是,这只会使您仅获得上周的推文。 To get the older tweets that you are interested in you will need to pay for Twitter's Enterprise service .
要获得您感兴趣的较旧的推文,您需要付费Twitter的Enterprise服务 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.