curl和jq命令

curl

curl is a tool to transfer data from or to a server.
support protocols:DICT 、FILE、 FTP、 FTPS、 GOPHER、 HTTP、 HTTPS、 IMAP,without user interaction

  • curl -x 指定代理端口,可配合Charles使用
curl -x 127.0.0.1:8888 https://www.baidu.com/
  • get,发送get请求
-G:使用get请求
-d:指定请求数据
curl https://www.baidu.com
curl -G https://www.baidu.com
curl -X GET https://www.baidu.com
  • post,发送post请求
-d:指定post请求体
curl -d ‘login = 1234' https://www.baidu.com
curl -X POST https://www.baidu.com
  • other,发送post请求
#保存响应内容
curl -o tmp.html https://www.baidu.com
#输出通信的整个过程
curl -v https://www.baidu.com
#不输出错误和进度信息
curl -s https://www.baidu.com

jq

A jq program is a filter , it takes an input,and produces an output , https://stedolan.github.io/jq/

使用

  • . 格式化
    echo '{"a":11,"b":12}' | jq '.',it takes an input , and produces an output.
  • 内容提取
    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]'
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值