curl_linux_command

curl命令

网页下载

1
2
3
4
5
# 以指定的文件名另存稻本地
curl -o lesson0.mp4 http://url/path/file.mp4

# 自动从URL中解析出文件名另存导本地
curl -O http://url/path/file.mp4

通配符支持

1
2
3
4
5
6
7
# 下载video1-4所有视频,按照video1.mp4 video2.mp4 a。。。保存
curl -o 'video#1.mp4' 'http://url/path/file[1-4].mp4'

curl -O http://url/path/file[1-4].mp4

# 可以指定步长
curl -O http://url/path/file[00-99:2].mp4

查看Http头部响应头

1
curl -I http://www.baidu.com

自动跟踪重定向

1
curl -L http://www.sina.com

指定HTTP请求方式

1
2
3
4
#发起post请求
curl -X POST
#发起update请求
curl -X UPDATE

自定义HTTP请求头

1
2
3
4
5
6
#cookie:
--cookie "name1=xxx;name2=xxx;name3=xxx" http:www.curltest.com
#referer:
--referer "<script>alert("I am admin,bitch!")</script>"
#ua
--user-agent "<script>alert("I am admin,bitch!S")"</script>

提交表单

1
2
# 可以上传多个参数
curl -X post -F "name=chihz" -F "age=22" -F "heading=@path/selection_translate.sh"

多进程下载

1
2
# 下载前500个字节的文件
curl -o -r'0-500' http://path/file.mp4