【问题标题】:GmailAPI: How can I get the next page of results for a certain query?GmailAPI:如何获取某个查询的下一页结果?
【发布时间】:2015-09-17 04:14:16
【问题描述】:

我使用某个查询来获取与特定搜索相对应的结果:

response = gmail_service.users().messages().list(userId=user_id, q='from:"digital-no-reply@amazon.com"', pageToken='').execute()

要获得下一页结果,这是正确的查询:

response = gmail_service.users().messages().list(userId=user_id, q='from:"digital-no-reply@amazon.com"', pageToken=next_page_token).execute()

我尝试不提供查询参数,认为 next_page_token 应该包含对生成上一页的查询的引用,但我得到的结果不是来自查询参数。因此想知道获取与查询对应的所有结果页面的正确方法是什么?

【问题讨论】:

    标签: gmail gmail-api


    【解决方案1】:

    你的怀疑是正确的。只需在您的下一页获取中提供相同的查询并重复,直到响应中没有 pageToken。然后您就知道您已经获得了该特定查询的所有结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-23
      • 2019-09-26
      • 2011-10-16
      • 1970-01-01
      • 2019-03-15
      • 2011-12-02
      • 2012-02-17
      • 1970-01-01
      相关资源
      最近更新 更多