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]'