O caminho certo com a solução jq
+ curl
:
Amostra válida input.json
:
{
"responseHeader": {
"status": 0,
"QTime": 7336
},
"response": {
"numFound": 50032,
"start": 0,
"maxScore": 1,
"docs": [
{
"documentURL": "https://unix.stackexchange.com/questions"
},
{
"documentURL": "https://unix.stackexchange.com/problems"
},
{
"documentURL": "https://stackoverflow.com/questions"
},
{
"documentURL": "https://stackoverflow.com/issues"
}
]
}
}
Processamento:
jq -r '.response.docs[].documentURL
| "curl -s -o /dev/null -I -w \"%{http_code} \(.)\n\" --url \(.)"' input.json \
| sh > http_codes.out
O conteúdo http_codes.out
resultante:
$ cat http_codes.out
200 https://unix.stackexchange.com/questions
404 https://unix.stackexchange.com/problems
200 https://stackoverflow.com/questions
404 https://stackoverflow.com/issues