curl 使用示例 详细

NAME
curl - transfer a URL

SYNOPSIS
curl [options] [URL...]

DESCRIPTION
curl is a client to get documents/files from or send documents to a server,
using any of the supported protocols (HTTP, HTTPS, FTP, GOPHER, DICT, TELNET, LDAP or FILE).
The command is designed to work without user interaction or any kind of interactivity.
curl offers a busload of useful tricks like proxy support, user authentication, ftp upload,
HTTP post, SSL (https:) connections,cookies, file transfer resume and more.

URL
The URL syntax is protocol dependent. You'll find a detailed description in RFC 2396.


查看响应头
curl -I http://www.bbc.com

保存到文件
curl -o filename http://www.bbc.com

绑定ip测试
curl -X"GET" -H"Host: tools.bbc.com" -O http:/shenfenzheng.htm

从ftp下载
curl -u test:test -O ftp:/a.txt
或curl -O ftp://test:test@*.*.*.*:21/zhuh.txt
    -O Write output to a file named as the remote file

上传至ftp
curl -T ./t.xt ftp://test:test@*.*.*.*:21/

指定referer
curl -e http://www.baidu.com http://www.bbc.com

代理
curl "http://iframe.ip138.com/ic.asp"
curl -x *.*.*.*:3333 "http://iframe.ip138.com/ic.asp"

保存cookie
curl -c ./cookie01 http:/setCookie.php
或curl -D ./dumpheader http:/setCookie.php

发送cookie到服务器
curl -b ./cookie01 http:/showCookie.php

指定UA
curl -v -A "User-AgentMozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20100101 Firefox/16.0"http://8.8.8.8/setCookie.php

续传
curl -C -O http://download.bbc.com/Setup_V2.4.exe

分块多进程下载
curl -r 0-1024000 -o "ie1" http://download.bbc.com/Setup_V2.4.exe &\
curl -r 1024001-2048000 -o "ie2" http://download.bbc.com/Setup_V2.4.exe &\
curl -r 2048001-4096000 -o "ie3" http://download.bbc.com/Setup_V2.4.exe &\
curl -r 4096001- -o "ie4" http://download.bbc.com/setupV2.4.exe &
cat ie* > ie.exe

使用POST方式提交表单
curl -d"cmd=login" -d"password=af8f9dffa5d420fbc2491416962ee" -d"username=testcurl"http://login.bbc.com/login.php

取状态码
curl -o /dev/null -s -w"%{http_code},%{time_total}" http://www.bbc.com

posted @ 2016-10-27 16:03  费曼带我飞  阅读(393)  评论(0编辑  收藏  举报