Linux curl命令使用笔记

《Linux curl命令使用笔记》

基本请求方法,只显示响应体:curl url

# curl http://127.0.0.1:8080/01.html

常见命令参数

# curl [-v] [url] //基本语法
# curl -I url //只显示头信息
# curl -i url //显示全部信息

# curl -v url //显示get请求全过程
# curl -X GET url //指定请求方式

# curl http://127.0.0.1/logo.gif > /dev/null 2>&1  //不输出任何内容

//POST请求
# curl -H "Content-type: application/json" -X POST 
-d '{"pkg": "com.taobao.app","country": "CN","ver": "1.0"}' url
-H:请求头(多个请求头写多个)
-d:请求体,例子中 post 请求发送 Json 字符串给服务器
url:请求url

//一般下载
curl -o test.gif http://127.0.0.1/logo.gif
-o:指定保存的位置
curl http://127.0.0.1/logo.gif > test.gif  //保存到指定文件

# curl -# http://127.0.0.1/logo.gif > test.gif //显示下载进度(-#)
# curl -s http://127.0.0.1/logo.gif > test.gif //静默下载(-#)
# curl -q http://127.0.0.1/logo.gif > test.gif //安静模式(无信息输出)
# curl -o test.gif -L http://127.0.0.1/logo.gif  //下载有重定向的链接
# curl –limit-rate 20K http://127.0.0.1/logo.gif > test.gif //限制最大下载速度
点赞

发表评论

邮箱地址不会被公开。 必填项已用*标注