详解Curl各参数的含义

news/2023/5/28 8:27:15
在这里插入图片描述

详解Curl各参数的含义

    • 1. Introduction
    • 2. Detail
      • 2.1 参数-k
      • 2.2 参数-X
      • 2.3 参数-x
      • 2.4 参数-w %{http_code}
      • 2.5 参数-d
      • 2.6 参数-H
      • 2.7 参数-F
      • 2.8 参数-O
      • 2.9 参数-o
      • 2.10 参数-u
      • 2.11 参数-b
      • 2.12 参数-G
    • 3. Awakening


在这里插入图片描述
在这里插入图片描述

在这里插入图片描述


1. Introduction

[root@nolan ~]# curl -h
Usage: curl [options...] <url>
Options: (H) means HTTP/HTTPS only, (F) means FTP only--anyauth       Pick "any" authentication method (H)-a, --append        Append to target file when uploading (F/SFTP)--basic         Use HTTP Basic Authentication (H)--cacert FILE   CA certificate to verify peer against (SSL)--capath DIR    CA directory to verify peer against (SSL)-E, --cert CERT[:PASSWD] Client certificate file and password (SSL)--cert-type TYPE Certificate file type (DER/PEM/ENG) (SSL)--ciphers LIST  SSL ciphers to use (SSL)--compressed    Request compressed response (using deflate or gzip)-K, --config FILE   Specify which config file to read--connect-timeout SECONDS  Maximum time allowed for connection-C, --continue-at OFFSET  Resumed transfer offset-b, --cookie STRING/FILE  String or file to read cookies from (H)-c, --cookie-jar FILE  Write cookies to this file after operation (H)--create-dirs   Create necessary local directory hierarchy--crlf          Convert LF to CRLF in upload--crlfile FILE  Get a CRL list in PEM format from the given file-d, --data DATA     HTTP POST data (H)--data-ascii DATA  HTTP POST ASCII data (H)--data-binary DATA  HTTP POST binary data (H)--data-urlencode DATA  HTTP POST data url encoded (H)--delegation STRING GSS-API delegation permission--digest        Use HTTP Digest Authentication (H)--disable-eprt  Inhibit using EPRT or LPRT (F)--disable-epsv  Inhibit using EPSV (F)-D, --dump-header FILE  Write the headers to this file--egd-file FILE  EGD socket path for random data (SSL)--engine ENGINGE  Crypto engine (SSL). "--engine list" for list-f, --fail          Fail silently (no output at all) on HTTP errors (H)-F, --form CONTENT  Specify HTTP multipart POST data (H)--form-string STRING  Specify HTTP multipart POST data (H)--ftp-account DATA  Account data string (F)--ftp-alternative-to-user COMMAND  String to replace "USER [name]" (F)--ftp-create-dirs  Create the remote dirs if not present (F)--ftp-method [MULTICWD/NOCWD/SINGLECWD] Control CWD usage (F)--ftp-pasv      Use PASV/EPSV instead of PORT (F)-P, --ftp-port ADR  Use PORT with given address instead of PASV (F)--ftp-skip-pasv-ip Skip the IP address for PASV (F)--ftp-pret      Send PRET before PASV (for drftpd) (F)--ftp-ssl-ccc   Send CCC after authenticating (F)--ftp-ssl-ccc-mode ACTIVE/PASSIVE  Set CCC mode (F)--ftp-ssl-control Require SSL/TLS for ftp login, clear for transfer (F)-G, --get           Send the -d data with a HTTP GET (H)-g, --globoff       Disable URL sequences and ranges using {} and []-H, --header LINE   Custom header to pass to server (H)-I, --head          Show document info only-h, --help          This help text--hostpubmd5 MD5  Hex encoded MD5 string of the host public key. (SSH)-0, --http1.0       Use HTTP 1.0 (H)--ignore-content-length  Ignore the HTTP Content-Length header-i, --include       Include protocol headers in the output (H/F)-k, --insecure      Allow connections to SSL sites without certs (H)--interface INTERFACE  Specify network interface/address to use-4, --ipv4          Resolve name to IPv4 address-6, --ipv6          Resolve name to IPv6 address-j, --junk-session-cookies Ignore session cookies read from file (H)--keepalive-time SECONDS  Interval between keepalive probes--key KEY       Private key file name (SSL/SSH)--key-type TYPE Private key file type (DER/PEM/ENG) (SSL)--krb LEVEL     Enable Kerberos with specified security level (F)--libcurl FILE  Dump libcurl equivalent code of this command line--limit-rate RATE  Limit transfer speed to this rate-l, --list-only     List only names of an FTP directory (F)--local-port RANGE  Force use of these local port numbers-L, --location      Follow redirects (H)--location-trusted like --location and send auth to other hosts (H)-M, --manual        Display the full manual--mail-from FROM  Mail from this address--mail-rcpt TO  Mail to this receiver(s)--mail-auth AUTH  Originator address of the original email--max-filesize BYTES  Maximum file size to download (H/F)--max-redirs NUM  Maximum number of redirects allowed (H)-m, --max-time SECONDS  Maximum time allowed for the transfer--metalink      Process given URLs as metalink XML file--negotiate     Use HTTP Negotiate Authentication (H)-n, --netrc         Must read .netrc for user name and password--netrc-optional Use either .netrc or URL; overrides -n--netrc-file FILE  Set up the netrc filename to use-N, --no-buffer     Disable buffering of the output stream--no-keepalive  Disable keepalive use on the connection--no-sessionid  Disable SSL session-ID reusing (SSL)--noproxy       List of hosts which do not use proxy--ntlm          Use HTTP NTLM authentication (H)-o, --output FILE   Write output to <file> instead of stdout--pass PASS     Pass phrase for the private key (SSL/SSH)--post301       Do not switch to GET after following a 301 redirect (H)--post302       Do not switch to GET after following a 302 redirect (H)--post303       Do not switch to GET after following a 303 redirect (H)-#, --progress-bar  Display transfer progress as a progress bar--proto PROTOCOLS  Enable/disable specified protocols--proto-redir PROTOCOLS  Enable/disable specified protocols on redirect-x, --proxy [PROTOCOL://]HOST[:PORT] Use proxy on given port--proxy-anyauth Pick "any" proxy authentication method (H)--proxy-basic   Use Basic authentication on the proxy (H)--proxy-digest  Use Digest authentication on the proxy (H)--proxy-negotiate Use Negotiate authentication on the proxy (H)--proxy-ntlm    Use NTLM authentication on the proxy (H)-U, --proxy-user USER[:PASSWORD]  Proxy user and password--proxy1.0 HOST[:PORT]  Use HTTP/1.0 proxy on given port-p, --proxytunnel   Operate through a HTTP proxy tunnel (using CONNECT)--pubkey KEY    Public key file name (SSH)-Q, --quote CMD     Send command(s) to server before transfer (F/SFTP)--random-file FILE  File for reading random data from (SSL)-r, --range RANGE   Retrieve only the bytes within a range--raw           Do HTTP "raw", without any transfer decoding (H)-e, --referer       Referer URL (H)-J, --remote-header-name Use the header-provided filename (H)-O, --remote-name   Write output to a file named as the remote file--remote-name-all Use the remote file name for all URLs-R, --remote-time   Set the remote file's time on the local output-X, --request COMMAND  Specify request command to use--resolve HOST:PORT:ADDRESS  Force resolve of HOST:PORT to ADDRESS--retry NUM   Retry request NUM times if transient problems occur--retry-delay SECONDS When retrying, wait this many seconds between each--retry-max-time SECONDS  Retry only within this period-S, --show-error    Show error. With -s, make curl show errors when they occur-s, --silent        Silent mode. Don't output anything--socks4 HOST[:PORT]  SOCKS4 proxy on given host + port--socks4a HOST[:PORT]  SOCKS4a proxy on given host + port--socks5 HOST[:PORT]  SOCKS5 proxy on given host + port--socks5-basic  Enable username/password auth for SOCKS5 proxies--socks5-gssapi Enable GSS-API auth for SOCKS5 proxies--socks5-hostname HOST[:PORT] SOCKS5 proxy, pass host name to proxy--socks5-gssapi-service NAME  SOCKS5 proxy service name for gssapi--socks5-gssapi-nec  Compatibility with NEC SOCKS5 server-Y, --speed-limit RATE  Stop transfers below speed-limit for 'speed-time' secs-y, --speed-time SECONDS  Time for trig speed-limit abort. Defaults to 30--ssl           Try SSL/TLS (FTP, IMAP, POP3, SMTP)--ssl-reqd      Require SSL/TLS (FTP, IMAP, POP3, SMTP)-2, --sslv2         Use SSLv2 (SSL)-3, --sslv3         Use SSLv3 (SSL)--ssl-allow-beast Allow security flaw to improve interop (SSL)--stderr FILE   Where to redirect stderr. - means stdout--tcp-nodelay   Use the TCP_NODELAY option-t, --telnet-option OPT=VAL  Set telnet option--tftp-blksize VALUE  Set TFTP BLKSIZE option (must be >512)-z, --time-cond TIME  Transfer based on a time condition-1, --tlsv1         Use => TLSv1 (SSL)--tlsv1.0       Use TLSv1.0 (SSL)--tlsv1.1       Use TLSv1.1 (SSL)--tlsv1.2       Use TLSv1.2 (SSL)--tlsv1.3       Use TLSv1.3 (SSL)--tls-max VERSION  Use TLS up to VERSION (SSL)--trace FILE    Write a debug trace to the given file--trace-ascii FILE  Like --trace but without the hex output--trace-time    Add time stamps to trace/verbose output--tr-encoding   Request compressed transfer encoding (H)-T, --upload-file FILE  Transfer FILE to destination--url URL       URL to work with-B, --use-ascii     Use ASCII/text transfer-u, --user USER[:PASSWORD]  Server user and password--tlsuser USER  TLS username--tlspassword STRING TLS password--tlsauthtype STRING  TLS authentication type (default SRP)--unix-socket FILE    Connect through this UNIX domain socket-A, --user-agent STRING  User-Agent to send to server (H)-v, --verbose       Make the operation more talkative-V, --version       Show version number and quit-w, --write-out FORMAT  What to output after completion--xattr        Store metadata in extended file attributes-q                 If used as the first parameter disables .curlrc

2. Detail

2.1 参数-k

  • 在发送https请求时,加上-k参数,否则会有如下证书的报错
    curl -k https://www.baidu.com/在这里插入图片描述

2.2 参数-X

  • 指定请求方法,如POST、GET等
    curl -k -X POST https://www.baidu.com
    curl -k -X GET https://XX -H ‘Cookie: session=eyJfcGVybWFuZW50IjpmYWxzZSwidXNlciI6eyJpZCI6MSwibmFtZSI6ImFkbWluIn19.YPovOg.oOLrM4Xgfs0qtw8-m4NxYLrpPks’

2.3 参数-x

  • 指定访问IP与端口号
    curl -k -x 192.168.4.12:80 https://www.baidu.com

2.4 参数-w %{http_code}

  • 返回值带上http响应码
    curl -k -w %{http_code} -X POST https://www.baidu.com
    curl -k -w %{time_connect}:%{time_starttransfer}:%{time_total} -X POST https://www.baidu.com

2.5 参数-d

  • 请求body(内容需要用单引号括起来)
    curl -k -w %{http_code} -X POST https://www.baidu.com -d ‘body内容’

2.6 参数-H

  • 添加header内容
    curl -k -w %{http_code} -X POST https://www.baidu.com -d ‘body内容’ -H ‘header内容’
    curl -H “Content-Type:application/json” -X POST -d ‘{“operator”: “killianxu”,“place_type”:“tt”}’ https://www.baidu.com

2.7 参数-F

  • body带文件
    curl -k -X POST https://www.baidu.com -F ‘file=@file_path’

2.8 参数-O

  • 将服务器回应保存成文件,并将 URL 的最后部分当作文件名
    curl -O http://www.baidu.com/index.html

2.9 参数-o

  • 将服务器的回应保存成文件,等同于wget命令
    curl -o example.html http://www.baidu.com

2.10 参数-u

  • curl提交用户名和密码
    curl http://name:passwd@www.baidu.com
    curl -u name:passwd http://www.baidu.com

2.11 参数-b

  • 携带cookie的请求
    和参数-H功能差不多
    curl -b ‘session=D0112A5063D938586B659EF8F939BE24’ http://www.baidu.com

2.12 参数-G

  • 用来构造 URL 的查询字符串
    https://google.com/search?q=kitties&count=20
    curl -G -d ‘q=kitties’ -d ‘count=20’ https://google.com/search
  • 如果数据需要 URL 编码,可以结合–data–urlencode参数
    curl -G --data-urlencode ‘comment=hello world’ https://www.example.com

3. Awakening

         在一秒钟内看到本质的人和花半辈子也看不清一件事本质的人,自然是不一样的命运。
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.exyb.cn/news/show-4571380.html

如若内容造成侵权/违法违规/事实不符,请联系郑州代理记账网进行投诉反馈,一经查实,立即删除!

相关文章

python黑科技自动p图_Python - AI自动抠图

一、简介 抠图是用PS&#xff1f; 用魔棒和快速选择工具&#xff1f; 遇到复杂背景怎么办&#xff1f; 最近发现一个神奇的工具——Remove Image Background 它是基于Python、Ruby和深度学习技术开发&#xff0c;通过强大的AI人工智能算法实现自动识别出前景主体与背景图&#…

我扒了37篇硅谷用户增长大神的blog,总结出这8点干货

作者&#xff1a;原子大大全文共 4388 字 9 图&#xff0c;阅读需要 10 分钟———— / BEGIN / ————最近关注了一批硅谷的增长大牛&#xff0c;Andrew Chen 是其中之一。看了他的 blog 收获多多&#xff0c;总结了8点知识模块干货&#xff0c;分享给大家。阅读时给大家个小…

不确定性弥漫的零食市场,三只松鼠如何交出确定性答案?

上半年&#xff0c;不确定性萦绕多行业。因此&#xff0c;今年的半年报披露期&#xff0c;成了考验时刻。 2022年8月19日&#xff0c;三只松鼠发布2022年上半年业绩。半年报显示&#xff0c;三只松鼠实现营收41.13亿元&#xff0c;归属于上市公司股东的净利润为8213万元&#…

蘑菇街TeamTalk源码流程思维导图

最近对蘑菇街的TeamTalk源码比较感兴趣&#xff0c;因此抽了部分时间去学习它的源码&#xff0c;获益匪浅&#xff0c;该篇文章列出了TeamTalk Login_Server的处理流程的思维导图&#xff0c;希望帮助大家阅读Login_Server的代码时有个宏观的了解。 当前的TEAMTALK ClientListe…

BAT蘑菇街等Java社招面试总结一二

毕业之后工作两年有余&#xff0c;对现在的工作及工作环境有些不满&#xff0c;出来找下工作&#xff0c;看看外面的世界&#xff0c;同时也试下自己的水平。 至今共面试了多家公司&#xff0c;包括大厂阿里、网易、蘑菇街等、也有多家创业型公司&#xff0c;收到多个offer。由…

linux每个进程的地址空间大小,别再说你不懂 Linux 内存管理了,10 张图给你安排的明明白白...

原标题&#xff1a;别再说你不懂 Linux 内存管理了&#xff0c;10 张图给你安排的明明白白转自&#xff1a;LemonCode过去的一周有点魔幻&#xff0c;有印象的有三个新闻&#xff1a;天猫总裁绯闻事件&#xff0c;蘑菇街裁员&#xff0c;不可能打工的周某也放出来了。三件事&am…

我是这样分析Linux性能问题的

在互联网公司普遍“996”的大环境下&#xff0c;大部分做应用的开发者&#xff0c;大都将精力集中在业务代码的优化和调配上&#xff0c;忽略了对 Linux 内核的学习。而且&#xff0c;这部分知识本身就很复杂&#xff0c;所以学习成本也比较高。但是&#xff0c;只要你经历过公…

Linux 性能问题,如何从内核层面解决?

很多大厂有专门负责性能优化的部分&#xff0c;他们的职责就是站在系统的层面解决各种疑难杂症&#xff0c;最大化的利用系统资源。这些工作能够靠谱的执行&#xff0c;都有一个前提&#xff0c;那就是需要对操作系统&#xff0c;对内核有一定的了解。在互联网公司普遍“996”的…

linux内存管理_别再说你不懂Linux内存管理了,10张图给你安排的明明白白!

过去的一周有点魔幻&#xff0c;有印象的有三个新闻&#xff1a;天猫总裁绯闻事件&#xff0c;蘑菇街裁员&#xff0c;不可能打工的周某也放出来了。三件事&#xff0c;两件和互联网行业相关&#xff0c;好像外面的世界很是精彩啊&#xff01;吃瓜归吃瓜&#xff0c;学习还是不…

VMware安装Linux系统及JDK部署

背景&#xff1a; 阅读新闻 [日期&#xff1a;2016-01-23] 来源&#xff1a;Linux社区 作者&#xff1a;xrq730 [字体&#xff1a;大 中 小] 前言 由于我的笔记本有点问题&#xff0c;所以这周系统包括所有硬盘全部重装了&#xff0c;原来的Linux虚拟机都没了&#xff0c;因此才…

Java面试--Linux

面试题&#xff1a;Linux查看cpu占用率高的进程(阿里面试题) 面试题&#xff1a;查看占用某端口的进程(阿里面试题) 面试题&#xff1a;查看某进程监听的端口(阿里面试题) 面试题&#xff1a;查看系统负载(今日头条面试题) 面试题&#xff1a;查看进程中线程的状态(蘑菇街面…

#第七章 双波不干涉理论 ​一、双波不干涉理论的分级方法

关于散点图的“另类”使用 在四维角度尺观察的拟合现象中&#xff0c;我们已经看到&#xff0c;每一级的行情都被分为四个趋势方向的点位密集区&#xff0c;这个密集区是随趋势方向喇叭口放大呈现的。也就是&#xff0c;如果我们用波动幅度来表达这个趋势&#xff0c;也会出现喇…

网络交换机的作用有哪些?

现如今&#xff0c;随着通信业的发展以及国民经济信息化的推进&#xff0c;网络交换机市场呈稳步上升态势&#xff0c;以太网技术已成为当今最重要的一种局域网组网技术&#xff0c;网络交换机也就成为了最普及的交换机。那么&#xff0c;网络交换机的作用有哪些呢&#xff1f;…

工业交换机和工控交换机有什么区别?

众所周知&#xff0c;以太网交换机一般分为&#xff1a;商用(以太网)交换机、工业(以太网)交换机、家用(以太网)交换机&#xff0c;因为我们是专业的工业交换机厂家&#xff0c;在这里着重介绍下工业交换机。 工业交换机一般用在工业生产场合&#xff0c;通常外观和安装形式多…

白牌交换机有哪些特点?和传统交换机比有什么特别?—Vecloud

目前&#xff0c;白牌交换机已经被广泛应用大型企业&#xff0c;在国外&#xff0c;例如Google、Facebook和微软这样的大型企业会使用白牌交换机来开发属于自己的网络软件。在国内&#xff0c;像百度、阿里巴巴和京东等大公司也尝试过这个模式。 这些大型企业使用裸机交换机的原…

二层与三层交换机之间有什么区别?

二层交换机通常用于连接以太网中的网络设备和客户端设备&#xff0c;以识别与转发数据包中的MAC地址。但随着网络应用程序多样性的增加以及融合网络应用的发展&#xff0c;三层交换机的应用在数据中心&#xff0c;复杂的企业网络&#xff0c;商业应用乃至高级客户项目中蓬勃发展…

什么是死信交换机

什么是死信&#xff1f; 当一个队列中的消息满足下列情况之一时&#xff0c;可以成为死信&#xff08;dead letter&#xff09;&#xff1a; 消费者使用basic.reject或 basic.nack声明消费失败&#xff0c;并且消息的requeue参数设置为false 消息是一个过期消息&#xff0c;超…

poe交换机归类有什么?

PoE供电技术性凭着简单化用电量设施的布署&#xff0c;及其环保节能、安全性、靠谱等优点&#xff0c;变成安防监控系统、无线网覆盖及其智慧能源等情景的新宠儿。在安防监控系统新项目中&#xff0c;大家时常会应用PoE交换机给无线网络AP、虚拟电话、网络摄像头等机器设备供电…

什么是交换机?它有哪些作用?

一 什么是交换机&#xff1f; 交换机&#xff08;Switch&#xff09;意为“开关”是一种用于电&#xff08;光&#xff09;信号转发的网络设备。它可以为接入交换机的任意两个网络节点提供独享的电信号通路。最常见的交换机是以太网交换机。其他常见的还有电话语音交换机、光纤…

thinkphp3.2.2有预览的多图上传

thinkphp3.2.2有预览的多图上传 thinkphp3.2.2有预览的多图上传 整体思路 1 封装文件上传和图片上传的类文件 2 视图中添加相关JS和表单提交 3 控制器中添加上传文件的相关代码 一 2个class 文件 请上传到/ThinkPHP/Library/Think/ UploadFile.class.php <?php namespace T…