我可以使用 Twitter api 搜索一周前的推文吗? [英] Can I use twitter api to search tweets one week before?

查看:42
本文介绍了我可以使用 Twitter api 搜索一周前的推文吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 tweepy 在 twitter 中搜索关键字.

I am trying to search keywords in twitter through tweepy.

但是,我发现好像搜索不到一周前的推文,下面的代码是主要的搜索代码.

However, I found it seems like that I can not search the tweets one week before, the code below is the main search code.

for searched_tweets in tweepy.Cursor( API.search,
                                      q = "python", 
                                      since = 2014-02-03, 
                                      until = 2014-02-04, 
                                      lang='en' ).items()

我不知道有没有限制或更好的时间搜索方式,谢谢你的帮助!!:)

I am not sure whether there is any limited or any better way to search by time, thanks for your help!! :)

推荐答案

很遗憾,您无法使用 twitter 搜索 API 获取超过一周的推文.

Unfortunately, you can't get tweets older than a week with the twitter search API.

另请注意,twitter.com 上的搜索结果可能会返回历史结果,而搜索 API 通常只提供过去一周的推文.- Twitter 文档.

Also note that the search results at twitter.com may return historical results while the Search API usually only serves tweets from the past week. - Twitter documentation.

您可以通过查看单个用户或使用特定的帖子 ID(如果有的话)来获取超过一周的特定推文,但是使用API.

You can get specific tweets older than a week by looking at individual users or using specific post ids (if you have them) but it's not reasonable to index every single tweet ever to be searchable using the API.

如果您需要较大的时间范围,您可以使用流媒体 API 自行收集它们或查看提供此功能的服务(请参阅此 dev twitter 线程 示例).

If you need a large time range, you can collect them yourself using the streaming API or check out a service that does (see this dev twitter thread for examples).

这篇关于我可以使用 Twitter api 搜索一周前的推文吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆