1

我的 django 项目中有一个场景,我需要检索所有mentions特定的 twitter 用户。我有用户的凭据。我已经尝试了搜索 api,但它提供的不够多,我无法提取所有提及,而且 twitter 设置的限制也阻碍了我寻求的内容。

因此,now I seek advice whether this can be achieved by the Streaming api or not?我还需要将检索到的推文详细信息存储在我的 mongodb 数据库中,以便我可以运行过滤器和自定义搜索。我为此使用 twython 包。

4

1 回答 1

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 将是经过身份验证的用户的所有检索到的提及的数组。

于 2013-12-17T07:28:53.230 回答