【问题标题】:Post request returns dictionary with empty list发布请求返回带有空列表的字典
【发布时间】:2022-07-05 21:08:00
【问题描述】:

试图用 python 从网站中减去一些数据。 我没有得到与浏览器开发者窗口中显示的相同的响应。

预览代码是浏览器返回的:

{$id: "989"...}
$id: "989"
rows:[{$id: "990",constructionId: 84, constructionUnitId: Null,...}]
0: {$id: "990",constructionId: 84, constructionUnitId: Null,...}
1: {$id: "991",constructionId: 108, constructionUnitId: Null,...}
2: {$id: "992",constructionId: 157, constructionUnitId: Null,...}
3: {$id: "993",constructionId: 186, constructionUnitId: Null,...}

我在 python 中得到的响应:

{'$id': '990', 'rows': []}

我使用的代码是:

Obj_req = s.post('https://########.com/api/v1/Projects/GetDetailedTree', json=data, headers=headers)
    Obj_req_js = Obj_req.json()
    a = json.loads(Obj_req.text)
    print(a)

如何获取此词典中的 constructionId 列表?

【问题讨论】:

    标签: python http-post


    【解决方案1】:

    您没有向服务器发送一些信息。例如错误的用户代理或缺少一些“保护变量标头”。

    接下来是您缺少网站加载时生成的 cookie。

    我无法发表评论,所以我发布答案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-15
      • 2021-08-02
      • 2022-11-15
      • 2020-09-15
      • 2017-07-23
      • 1970-01-01
      • 2018-01-03
      相关资源
      最近更新 更多