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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值