shell神器curl命令的用法 curl用法实例笔记
发布时间:2014-12-03 编辑:jiaochengji.com
本文介绍下,一个shell神器,它就是curl命令,通过一些精巧的例子,深入学习下curl命令的用法,有需要的朋友参考下。
shell神器curl命令的用法举例,如下:
复制代码 代码示例:
##基本用法(配合sed/awk/grep)
$curl http://www.jiaochengji.com
##下载保存
$curl http://www.jiaochengji.com > index.html
$curl -o index.html http://www.jiaochengji.com
$curl -O http://www.jiaochengji.com/target.tar.gz
##通过代理
$curl -x 123.45.67.89:1080 -o page.html http://www.jiaochengji.com
##保存cookie
$curl -x 123.45.67.89:1080 -o page1.html -D cookie0001.txt http://www.jiaochengji.com
##使用cookie
$curl -x 123.45.67.89:1080 -o page1.html -D cookie0002.txt -b cookie0001.txt http://www.jiaochengji.com
##模仿浏览器
$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.jiaochengji.com
##伪造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.jiaochengji.com
##循环下载
$curl -O http://www.jiaochengji.com/~zzh/screen[1-10].JPG
##循环(匹配)下载
$curl -O http://www.jiaochengji.com/~{zzh,nick}/[001-201].JPG # >like zzh/001.JPG
##循环(引用)下载
$curl -o #2_#1.jpg http://www.jiaochengji.com/~{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.jiaochengji.com/~zzh/zhao1.mp3 &\
$curl -r 10241 - 20480 -o "zhao.part1" http://www.jiaochengji.com/~zzh/zhao1.mp3 &\
$curl -r 20481 - 40960 -o "zhao.part1" http://www.jiaochengji.com/~zzh/zhao1.mp3 &\
$curl -r 40961 - -o "zhao.part1" http://www.jiaochengji.com/~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.jiaochengji.com/~zzh/up_file.cgi
$curl http://www.jiaochengji.com
##下载保存
$curl http://www.jiaochengji.com > index.html
$curl -o index.html http://www.jiaochengji.com
$curl -O http://www.jiaochengji.com/target.tar.gz
##通过代理
$curl -x 123.45.67.89:1080 -o page.html http://www.jiaochengji.com
##保存cookie
$curl -x 123.45.67.89:1080 -o page1.html -D cookie0001.txt http://www.jiaochengji.com
##使用cookie
$curl -x 123.45.67.89:1080 -o page1.html -D cookie0002.txt -b cookie0001.txt http://www.jiaochengji.com
##模仿浏览器
$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.jiaochengji.com
##伪造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.jiaochengji.com
##循环下载
$curl -O http://www.jiaochengji.com/~zzh/screen[1-10].JPG
##循环(匹配)下载
$curl -O http://www.jiaochengji.com/~{zzh,nick}/[001-201].JPG # >like zzh/001.JPG
##循环(引用)下载
$curl -o #2_#1.jpg http://www.jiaochengji.com/~{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.jiaochengji.com/~zzh/zhao1.mp3 &\
$curl -r 10241 - 20480 -o "zhao.part1" http://www.jiaochengji.com/~zzh/zhao1.mp3 &\
$curl -r 20481 - 40960 -o "zhao.part1" http://www.jiaochengji.com/~zzh/zhao1.mp3 &\
$curl -r 40961 - -o "zhao.part1" http://www.jiaochengji.com/~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.jiaochengji.com/~zzh/up_file.cgi
您可能感兴趣的文章:
shell神器curl命令的用法 curl用法实例笔记
使用curl获取网站的http的状态码
PHP CURL获取cookies模拟登录的方法介绍
curl模拟http请求范例详析
php下载css中图片函数
php curl存储cookie实例
php file_get_contents函数抓取页面信息的代码
php curl模拟post请求的例子
linux使用curl监控网页的shell脚本
php模拟登录qq邮箱(curl命令详解)
[关闭]