【问题标题】:Issue with fetching tweets from timeline as Twitter doesnt return 'next_results'由于 Twitter 不返回“next_results”,因此从时间线获取推文的问题
【发布时间】:2014-03-08 06:52:24
【问题描述】:

我正在尝试使用 next_results 中的 max_id 字段从 Twitter 时间线获取推文,如此处所示。(Twython search API with next_results)

对于大多数查询,我得到了所需数量(500+)的推文,但对于某些查询,我得到的推文少于 200 条。

查看 'next_results 中返回的内容时,我发现仅返回 100 条推文后,响应中缺少 next_results 字段。查询的主题不可能只有 200 条推文,因为我正在搜索该主题时正在流行,而在 Twitter 上我可以看到超过 200 条推文。

是否还有其他人也面临这个问题。有什么解决方法吗?

以下是第二个响应中缺少'next_results' 字段的输出。

TEST_PROGRAM >> Calling twitter to get tweets for  #TheWorstLieEver

{u'count': 100, u'completed_in': 0.066, u'max_id_str': u'432942833725497345', u'since_id_str': u'0', **u'next_results': u'?max_id=432540545630494719&q=%23TheWorstLieEver&count=100&include
_entities=1&result_type=mixed'**, u'refresh_url': u'?since_id=432942833725497345&q=%23TheWorstLieEver&result_type=mixed&include_entities=1', u'since_id': 0, u'query': u'%23TheWorstLieEver
', u'max_id': 432942833725497345L}

{u'count': 100, u'completed_in': 0.111, u'max_id_str': u'432540545630494719', u'since_id_str': u'0', u'refresh_url': u'?since_id=432540545630494719&q=%23TheWorstLieEver&result_type=mixe
d&include_entities=1', u'since_id': 0, u'query': u'%23TheWorstLieEver', u'max_id': 432540545630494719L}

【问题讨论】:

  • 嘿,你找到解决办法了吗?我也遇到了同样的问题
  • @ColinBernet 似乎实现自己的 max_id 导航可以获得更多结果。这意味着,当我们收到没有next_results 的响应时,我们需要手动查找具有最小推文ID 的推文,并在下一个查询中将其提交为max_id。你可以在这里找到它的参考:link。我试过了,但它没有给我更多的推文!
  • @ColinBernet 我得到了答案。如果您正在寻找音量,则需要使用 Streaming API。 Twitter 搜索 API 侧重于查询的相关性,因此可能不会返回所有推文。 [Twitter 文档] (dev.twitter.com/docs/using-search) 说 Before getting involved, it's important to know that the Search API is focused on relevance and not completeness. This means that some Tweets and users may be missing from search results. If you want to match for completeness you should consider using a Streaming API instead.
  • @kundan:既然您找到了解决方案,您应该将其添加为您问题的答案并接受它。
  • @Aaron 感谢您的指点。我会做的。

标签: twitter tweepy twython


【解决方案1】:

我得到了答案。如果您正在寻找音量,则需要使用 Streaming API。 Twitter 搜索 API 侧重于查询的相关性,因此可能不会返回所有推文。 Twitter documentation 说在参与之前,重要的是要知道 Search API 专注于相关性而不是完整性。这意味着搜索结果中可能会丢失一些推文和用户。如果您想匹配完整性,您应该考虑使用 Streaming API。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-27
    • 2013-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-09
    • 2012-12-17
    • 1970-01-01
    相关资源
    最近更新 更多