【发布时间】:2020-11-15 08:31:14
【问题描述】:
curl -H "Accept: application/json" 'http://example.com'
我得到的回应是
{"next":"/gibberish"}
所以我执行另一个请求:
curl -H "Accept: application/json" 'http://example.com/gibberish'
我得到的回应是
{"next":"/anotherGibberish"}
我希望能够执行 curl 请求,获取 next 信息并循环进入下一个请求。
你们知道如何在 bash 中执行此操作吗?
编辑: 任何使用 jq 的帮助也会很棒。 最后一个响应是一个身份验证失败的 JSON 响应 - 我应该停止循环。
{"unauthorized":"Authenticate with username and password"}
【问题讨论】:
-
@oguzismail 当没有
{"next":"/anotherGibberish"}response 时 -
是的。最后的响应是认证失败
{"unauthorized":"Authenticate with username and password"}