如何使用CURL工具及简单介绍

curl在命令行或脚本中用于传输数据,可用于汽车、电视机、路由器、打印机、音频设备、移动电话、平板电脑、机顶盒、媒体播放器,是数千个软件应用的互联网传输引擎100亿次安装。几乎全球每一个使用互联网的人每天都在使用curl。

      支持DICT、FILE、FTP、FTPS、GOPHER、GOPHERS、HTTP、HTTPS、IMAP、IMAPS、LDAP、LDAPS、MQTT、POP3、POP3S、RTMP、RTMPS、RTSP、SCP、SFTP、SMB、SMBS、SMTP、SMTPS、TELNET和TFTP。curl支持SSL证书、HTTP POST、HTTP PUT、FTP上传、基于HTTP表单的上传、代理、HTTP/2、HTTP/3、cookies、用户+密码认证(Basic、Plain、Digest、CRAM-MD5、SCRAM-SHA、NTLM、conference和Kerberos)、文件传输简历、代理隧道等等

curl安装Windows

下载地址:  https://curl.se/windows/

下载后解压 

使用命令行进入curl-7.80.0-win64-mingw\bin路径下后

curl --version 查看版本信息

D:\Soft\curl-7.80.0-win64-mingw\bin>curl --version
curl 7.80.0 (x86_64-pc-win32) libcurl/7.80.0 OpenSSL/3.0.0a (Schannel) zlib/1.2.11 brotli/1.0.9 zstd/1.5.0 libidn2/2.3.2 libssh2/1.10.0 nghttp2/1.46.0 li
Release-Date: 2021-11-10
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli gsasl HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz MultiSSL NTLM SPNEGO SSL SSPI TLS-SRP UnixSockets zstd

curl --help获取帮助

C:\Windows\system32>d:

D:\>cd D:\Soft\curl-7.80.0-win64-mingw\bin

D:\Soft\curl-7.80.0-win64-mingw\bin>
D:\Soft\curl-7.80.0-win64-mingw\bin>

D:\Soft\curl-7.80.0-win64-mingw\bin>curl --help
Usage: curl [options...] <url>
 -d, --data <data>          HTTP POST data
 -f, --fail                 Fail silently (no output at all) on HTTP errors
 -h, --help <category>      Get help for commands
 -i, --include              Include protocol response headers in the output
 -o, --output <file>        Write to file instead of stdout
 -O, --remote-name          Write output to a file named as the remote file
 -s, --silent               Silent mode
 -T, --upload-file <file>   Transfer local FILE to destination
 -u, --user <user:password> Server user and password
 -A, --user-agent <name>    Send User-Agent <name> to server
 -v, --verbose              Make the operation more talkative
 -V, --version              Show version number and quit

-H: “Content-type: application/json” 添加 HTTP 请求头 curl -H 'Content-type: application/json' $url

-G: 把data数据当成get请求的参数发送,用来构造 URL 的查询字符串,与–data-urlencode结合使用

-X:指定 HTTP 请求的方法 curl -X POST $url

-d: 发送post请求数据,@file表示来自于文件

–data-urlencode:发送post请求数据,会对内容进行url编码

-u: username:password用户认证

-o: 写文件,将服务器的响应保存成文件

-v: verbose,打印更详细日志

-s: 关闭一些提示输出,不输出错误和进度信息。

-S:只输出错误信息

例如执行  curl http://www.baidu.com

   上一篇:如何使用SoapUI - Soap测试工具

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

=PNZ=BeijingL

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值