shell神器curl命令的用法 curl用法实例笔记

shell神器curl命令的用法举例,如下:

##基本用法(配合sed/awk/grep)
$curl http://www.jquerycn.cn
 
##下载保存
$curl http://www.jquerycn.cn > index.html
$curl -o index.html http://www.jquerycn.cn
$curl -O http://www.jquerycn.cn/target.tar.gz
 
##通过代理
$curl -x 123.45.67.89:1080 -o page.html http://www.jquerycn.cn
 
##保存cookie
$curl -x 123.45.67.89:1080 -o page1.html -D cookie0001.txt http://www.jquerycn.cn
 
##使用cookie
$curl -x 123.45.67.89:1080 -o page1.html -D cookie0002.txt -b cookie0001.txt http://www.jquerycn.cn
 
##模仿浏览器
$curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -x 123.45.67.89:1080 -o page.html -D cookie0001.txt http://www.jquerycn.cn
 
##伪造referer
$curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -x 123.45.67.89:1080 -e "mail.yahoo.com" -o page.html -D cookie0001.txt http://www.jquerycn.cn
 
##循环下载
$curl -O http://www.jquerycn.cn/~zzh/screen[1-10].JPG
 
##循环(匹配)下载
$curl -O http://www.jquerycn.cn/~{zzh,nick}/[001-201].JPG  # >like zzh/001.JPG 
 
##循环(引用)下载
$curl -o #2_#1.jpg http://www.jquerycn.cn/~{zzh,nick}/[001-201].JPG # like >001_zzh.jpg
 
##断点续传
$curl -c -O http://cgi2.tky.3wb.ne.jp/~zzh/screen1.JPG  
 
##分块下载
$curl -r  0 - 10240  -o  "zhao.part1"  http://www.jquerycn.cn/~zzh/zhao1.mp3 &  
$curl -r 10241 - 20480  -o  "zhao.part1"  http://www.jquerycn.cn/~zzh/zhao1.mp3 &  
$curl -r 20481 - 40960  -o  "zhao.part1"  http://www.jquerycn.cn/~zzh/zhao1.mp3 &  
$curl -r 40961 - -o  "zhao.part1"  http://www.jquerycn.cn/~zzh/zhao1.mp3  
...
$cat zhao.part* > zhao.mp3
 
##GET 上传
$curl http://www.yahoo.com/login.cgi?user=nickwolfe&password=12345   
 
##POST 上传
$curl -d "user=nickwolfe&password=12345" http://www.yahoo.com/login.cgi 
 
##POST 文件上传
$curl -F upload= $localfile  -F $btn_name=$btn_value http://www.jquerycn.cn/~zzh/up_file.cgi
原文地址:https://www.cnblogs.com/clarke/p/5454609.html