我的django项目中有一个场景,我需要检索特定Twitter用户的所有mentions
。我有用户的凭据。我已经尝试了搜索api,它没有提供足够的,我无法提取所有提及,而且twitter设置的限制阻碍了我所寻求的。
所以,now I seek advice whether this can be achieved by the Streaming api or not?
我还需要将检索到的推文详细信息存储在我的mongodb数据库中,以便我可以运行过滤和自定义搜索。我正在使用twython包。
答案 0 :(得分:0)
我不确定您是否尝试从经过身份验证的用户检索它,但如果您这是我想出的。不确定这是不是最好的方式。
m = twitter.get_mentions_timeline(count=200)
calls = 1
id = m[-1]['id']
next_id = -1
# will continue calling mentions timeline until you hit rate limit
# or there are no more mentions of authenticated user
while id != next_id and calls < 16:
temp = twitter.get_mentions_timeline(count=200,max_id=id)
calls += 1
next_id = temp[-1]['id']
if id != next_id:
m += temp
next_id = -1
id = temp[-1]['id']
m将是经过身份验证的用户的所有检索提及的数组。