curl简介curl是一个开源的命令行工具,它基于网络协议,通过网络传输指定的URL。显示在“标准输出”(stdout)上。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的参数也很多。下面主要介绍HTTP和HTTPS相关的参数。建议将它们保存为收藏夹。参数速查表参数说明示例-A,--user-agent发送指定的User-Agent到服务器curl-A"Agent007"https://one.more--alt-svc使用此缓存文件启用alt-svccurl--alt-svcsvc.txthttps://one.more--anyauth选择任何身份验证方法curl--anyauth--userme:pwdhttps://one.more--compressed请求压缩(使用deflate或gzip)curl--compressedhttps://one.more-b,--cookie发送cookie的字符串,或者读取文件位置发送cookiecurl-bcookies.txthttps://one.more-c,--cookie-jar运行结束后将cookies写入指定文件curl-ccookies.txthttps://one.more-d,--dataHTTPPOSTdatacurl-d"name=onemore"https://one.more--data-asciiHTTPPOSTASCII数据curl--data-ascii@filehttps://one.more--data-binaryHTTPPOST的二进制数据curl--data-binary@filehttps://one.more--data-rawHTTPPOST的数据(不对@字符进行特殊解析)curl--data-raw"one@more"https://one.more--data-urlencodeHTTPPOSTcurl的url编码数据--data-urlencodename=onemorehttps://one.more--digestaccessusingHTTPdigestauthenticationcurl-你的名字:password--digesthttps://one.more--disallow-username-in-url禁止在url中输入用户名curl--disallow-username-in-urlhttps://one.more-D,--dump-header将接收到的header写入指定文件curl--dump-headerheader.txthttps://one.more-e,--referer指定Referrer的URLcurl--referer"https://more.one"https://one.more--etag-compare从文件中以ETag的形式读取文件头curl--etag-compareetag.txthttps://one.more--etag-save从请求中解析出ETag并保存到指定文件中curl--etag-saveetag.txthttps://one.more--expect100-timeout允许等待100-continue响应最长时间(以秒为单位)对于curl--expect100-timeout2.5https://one.more-f,--fail不要在服务器错误时显示HTTP错误消息curl--failhttps://one.more-F,--form模拟用户按下提交表单curl-Fimage=@onemore.jpghttps://one.more--form-string模拟用户按下提交表单(值字符串)curl--form-string"data"https://one.more-G,--get将POST数据放入URL并发起GET请求curl--get-d"name=onemore"https://one.more--haproxy-protocol发送HAProxyPROXYv1的headercurl--haproxy-protocolhttps://one.more-i,--include在输出中包含HTTP响应头curl-ihttps://one.more-I,--head只显示响应头curl-Ihttps://one.more-H,--header发送自定义标头curl-H"Content-Type:application/json;charset=UTF-8"https://one.more--hstsEnable用于传输的HSTScurl--hstscache.txthttps://one.more--http0.9使用HTTP0.9curl--http0.9https://one.more-0,--http1.0使用HTTP1.0curl--http1.0https://one.more--http1.1使用HTTP1.1curl--http1.1https://one.more--http2使用HTTP2curl--http2https://one。more--http2-prior-knowledge使用HTTP2(不使用HTTP/1.1升级)curl--http2-prior-knowledgehttps://one.more--http3使用HTTP3curl--http3https://one.more--ignore-content-length忽略服务器资源大小curl--ignore-content-lengthhttps://one.more-j,--junk-session-cookies忽略从文件中读取的会话cookiecurl--junk-session-cookies-bcookies.txthttps://one.more-L,--location启用重定向curl--Lhttps://one.more--location-trusted启用重定向并向其他主机发送认证信息curl--location-trusted-uuser:pwdhttps://one.more--max-redirs最大重定向次数curl--max-redirs3--locationhttps://one.more--negotiate使用HTTP协商(SPNEGO)身份验证curl--negotiate-u:https://one。more--no-alpn禁用ALPNTLS扩展curl--no-alpnhttps://one.more--no-npn禁用NPNTLS扩展curl--no-npnhttps://one.more--ntlm使用HTTPNTLM认证curl--ntlm-uuser:pwdhttps://one.more--ntlm-wb使用HTTPNTLM认证(使用ntlmauth程序进行认证)curl--ntlm-wb-uuser:pwdhttps://one.more--post301在301重定向后不切换到GET请求curl--post301--locationhttps://one.more--post302在302重定向后不切换到GET请求curl--post302--locationhttps://one.more--post303303重定向后不切换到GET请求curl--post303--locationhttps://one.more-r,--range只接受范围内的词Sectioncurl--range22-44https://one.more--raw禁用所有内部HTTP内容解码或transfer-encodingcurl--rawhttps://one.more--tr-encoding请求压缩transfer-encoding算法,并解压接收到的数据curl--tr-encodinghttps://one.more-v,--verbose显示整个通信过程,包括端口连接和头信息curl-vhttps://one.more-z,--time-cond