【问题标题】:Json query only returns first 2000 results - how do I get the rest?Json 查询仅返回前 2000 个结果 - 我如何获得其余的?
【发布时间】:2021-08-26 22:40:58
【问题描述】:

我正在尝试查询 Legiscan API 并下拉所有“通过”州立法机构的法案 我当前的查询:https://api.legiscan.com/?key=APIKEY&op=searchRaw&state=ALL&query=status:passed

仅返回24409 中的第一个2000 结果。我查看了 through the documentation 并尝试使用返回的 json 文件的摘要部分中的查询的不同变体修改 status:passed 部分:

{'status': 'OK', 'searchresult': {'summary': {'page': '1 of 13', 'range': '1 - 2000', 'relevancy':
'100% - 100%', 'count': 24409, 'page_current': 1, 'page_total': 13, 'query': '(XSTATUS4:(pos=1))'}

我试过了:

https://api.legiscan.com/?key=APIKEY&op=searchRaw&state=ALL&query=status:passed&pos:2

还有:

https://api.legiscan.com/?key=APIKEY&op=searchRaw&state=ALL&query=status:passed&XSTATUS4:pos=2

两个结果返回相同的结果。我怎样才能得到其他结果?我正在使用 Python 和 Jupyter Notebook。

【问题讨论】:

  • 大多数 API 对它们一次返回的结果数量都有限制,您必须不断循环调用它才能获得其余的结果。
  • 查看关于page参数的文档的第20页。
  • @JohnGordon 谢谢。

标签: python json pandas jupyter-notebook


【解决方案1】:

https://api.legiscan.com/?key=APIKEY&op=searchRaw&state=ALL&query=status:passed&page=2

需要添加page参数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-12
    • 1970-01-01
    相关资源
    最近更新 更多