Python Twitter 搜索.tweets 直到

3 投票
1 回答
7380 浏览
提问于 2025-04-17 17:50

我正在使用Python的Twitter搜索API,具体可以在这个链接找到:https://github.com/sixohsix/twitter

当我尝试使用“until”这个参数进行搜索时,结果却什么都没有返回。

from twitter import *

t = Twitter(auth=OAuth(....))

t.search.tweets(q = 'hello', count=3, until='2012-01-01')
{u'search_metadata': {u'count': 3, u'completed_in': 0.007, u'max_id_str': u'9223372036854775807', u'since_id_str': u'0', u'refresh_url': u'?since_id=9223372036854775807&q=hello%20until%3A2012-01-01&include_entities=1', u'since_id': 0, u'query': u'hello+until%3A2012-01-01', u'max_id': 9223372036854775807L}, u'statuses': []}

但是如果我不使用“until”参数进行搜索,就能正常找到推文。当我在twitter.com/search上手动搜索时,

https://twitter.com/search?q=hello%20until%3A2012-01-01&src=typd

也能正常找到推文。

有没有什么想法?

1 个回答

6

这段话主要讲的是Twitter的API搜索限制。引用自官方文档

你不能使用搜索API来查找大约一周之前的推文。

比如,你可以尝试运行一下

print t.search.tweets(q='hello', count=3, until='2013-03-01')

你会看到一些结果。

另外,看看这个回答

撰写回答