curl https://www.baidu.com 默认使用get
curl -G https://www.baidu.com 指定get
curl -X GET https://www.baidu.com
curl -d ‘login=1234’ https://www.baidu.com
curl -X POST https://www.baidu.com
- 保存响应内容
curl -o tmp.html https://www.baidu.com
- 输出通信的整个过程
curl -v https://www.baidu.com
- 不输出错误和进度信息
curl -s https://www.baidu.com
- 安装brew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
2.安装jq
brew install jq
echo '{"a":11,"b":12}' |jq .
- 提取foo
echo '{"foo":42,"bar":"less interesting data"}'|jq .foo
- 从数组中提取单个数据
echo '[{"a":1,"b":2},{"c":3,"d":4}]' | jq '.[0]'
- 从数组中提取所有数据
echo '[{"a":1,"b":2},{"c":3,"d":4}]' | jq '.[]'
- 过滤多个值
echo '[{"a":1,"b":2},{"c":3,"d":4}]' | jq '.[0,1]'
- 数据重组成数组
echo '{"a":1,"b":2,"c":3,"d":4}' | jq '[.a,.b]'
- 数据重组成对象
echo '{"a":1,"b":2,"c":3,"d":4}' | jq '{"tmp":.b}'