mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-19 21:51:20 +08:00
doc: update curl.md
. c060c36559
This commit is contained in:
@ -41,7 +41,7 @@
|
|||||||
<p>此 <a href="https://github.com/curl/curl">Curl</a> 备忘清单包含命令和一些常见的 Curl 技巧示例。</p>
|
<p>此 <a href="https://github.com/curl/curl">Curl</a> 备忘清单包含命令和一些常见的 Curl 技巧示例。</p>
|
||||||
</div></header><div class="menu-tocs"><div class="menu-btn"><svg aria-hidden="true" fill="currentColor" height="1em" width="1em" viewBox="0 0 16 16" version="1.1" data-view-component="true">
|
</div></header><div class="menu-tocs"><div class="menu-btn"><svg aria-hidden="true" fill="currentColor" height="1em" width="1em" viewBox="0 0 16 16" version="1.1" data-view-component="true">
|
||||||
<path fill-rule="evenodd" d="M2 4a1 1 0 100-2 1 1 0 000 2zm3.75-1.5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zM3 8a1 1 0 11-2 0 1 1 0 012 0zm-1 6a1 1 0 100-2 1 1 0 000 2z"></path>
|
<path fill-rule="evenodd" d="M2 4a1 1 0 100-2 1 1 0 000 2zm3.75-1.5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zM3 8a1 1 0 11-2 0 1 1 0 012 0zm-1 6a1 1 0 100-2 1 1 0 000 2z"></path>
|
||||||
</svg></div><div class="menu-modal"><a aria-hidden="true" class="leve2 tocs-link" href="#入门">入门</a><a aria-hidden="true" class="leve3 tocs-link" href="#介绍">介绍</a><a aria-hidden="true" class="leve3 tocs-link" href="#options">Options</a><a aria-hidden="true" class="leve3 tocs-link" href="#请求">请求</a><a aria-hidden="true" class="leve3 tocs-link" href="#数据">数据</a><a aria-hidden="true" class="leve3 tocs-link" href="#头信息-headers">头信息 Headers</a><a aria-hidden="true" class="leve3 tocs-link" href="#ssl">SSL</a><a aria-hidden="true" class="leve4 tocs-link" href="#安装">安装</a><a aria-hidden="true" class="leve2 tocs-link" href="#示例">示例</a><a aria-hidden="true" class="leve3 tocs-link" href="#curl-gethead">CURL GET/HEAD</a><a aria-hidden="true" class="leve3 tocs-link" href="#多文件上传">多文件上传</a><a aria-hidden="true" class="leve3 tocs-link" href="#为-curl-响应美化-json-输出">为 curl 响应美化 json 输出</a><a aria-hidden="true" class="leve3 tocs-link" href="#curl-post">CURL POST</a><a aria-hidden="true" class="leve3 tocs-link" href="#curl-脚本安装-rvm">CURL 脚本安装 rvm</a><a aria-hidden="true" class="leve3 tocs-link" href="#curl-高级">CURL 高级</a><a aria-hidden="true" class="leve3 tocs-link" href="#检查网站响应时间">检查网站响应时间</a><a aria-hidden="true" class="leve3 tocs-link" href="#使用-curl-检查远程资源是否可用">使用 Curl 检查远程资源是否可用</a><a aria-hidden="true" class="leve3 tocs-link" href="#正在下载文件">正在下载文件</a><a aria-hidden="true" class="leve3 tocs-link" href="#下载文件保存文件而不更改其名称">下载文件,保存文件而不更改其名称</a><a aria-hidden="true" class="leve3 tocs-link" href="#继续部分下载">继续部分下载</a><a aria-hidden="true" class="leve3 tocs-link" href="#从多个域下载文件">从多个域下载文件</a><a aria-hidden="true" class="leve3 tocs-link" href="#下载一系列文件">下载一系列文件</a></div></div><div class="h1wrap-body"><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="入门"><a aria-hidden="true" tabindex="-1" href="#入门"><span class="icon icon-link"></span></a>入门</h2><div class="wrap-body">
|
</svg></div><div class="menu-modal"><a aria-hidden="true" class="leve2 tocs-link" href="#入门">入门</a><a aria-hidden="true" class="leve3 tocs-link" href="#介绍">介绍</a><a aria-hidden="true" class="leve3 tocs-link" href="#options">Options</a><a aria-hidden="true" class="leve3 tocs-link" href="#请求">请求</a><a aria-hidden="true" class="leve3 tocs-link" href="#数据">数据</a><a aria-hidden="true" class="leve3 tocs-link" href="#头信息-headers">头信息 Headers</a><a aria-hidden="true" class="leve3 tocs-link" href="#ssl">SSL</a><a aria-hidden="true" class="leve4 tocs-link" href="#安装">安装</a><a aria-hidden="true" class="leve2 tocs-link" href="#示例">示例</a><a aria-hidden="true" class="leve3 tocs-link" href="#curl-gethead">CURL GET/HEAD</a><a aria-hidden="true" class="leve3 tocs-link" href="#多文件上传">多文件上传</a><a aria-hidden="true" class="leve3 tocs-link" href="#为-curl-响应美化-json-输出">为 curl 响应美化 json 输出</a><a aria-hidden="true" class="leve3 tocs-link" href="#curl-post">CURL POST</a><a aria-hidden="true" class="leve3 tocs-link" href="#curl-脚本安装-rvm">CURL 脚本安装 rvm</a><a aria-hidden="true" class="leve3 tocs-link" href="#curl-高级">CURL 高级</a><a aria-hidden="true" class="leve3 tocs-link" href="#检查网站响应时间">检查网站响应时间</a><a aria-hidden="true" class="leve3 tocs-link" href="#使用-curl-检查远程资源是否可用">使用 Curl 检查远程资源是否可用</a><a aria-hidden="true" class="leve3 tocs-link" href="#正在下载文件">正在下载文件</a><a aria-hidden="true" class="leve3 tocs-link" href="#下载文件保存文件而不更改其名称">下载文件,保存文件而不更改其名称</a><a aria-hidden="true" class="leve3 tocs-link" href="#继续部分下载">继续部分下载</a><a aria-hidden="true" class="leve3 tocs-link" href="#从多个域下载文件">从多个域下载文件</a><a aria-hidden="true" class="leve3 tocs-link" href="#下载一系列文件">下载一系列文件</a><a aria-hidden="true" class="leve3 tocs-link" href="#将输出重定向到文件">将输出重定向到文件</a><a aria-hidden="true" class="leve3 tocs-link" href="#基本认证">基本认证</a><a aria-hidden="true" class="leve3 tocs-link" href="#写入文件而不是标准输出">写入文件而不是标准输出</a><a aria-hidden="true" class="leve3 tocs-link" href="#下载头信息">下载头信息</a><a aria-hidden="true" class="leve3 tocs-link" href="#将输出写入名为远程文件的文件">将输出写入名为远程文件的文件</a><a aria-hidden="true" class="leve3 tocs-link" href="#执行远程脚本">执行远程脚本</a><a aria-hidden="true" class="leve3 tocs-link" href="#配置文件">配置文件</a></div></div><div class="h1wrap-body"><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="入门"><a aria-hidden="true" tabindex="-1" href="#入门"><span class="icon icon-link"></span></a>入门</h2><div class="wrap-body">
|
||||||
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="介绍"><a aria-hidden="true" tabindex="-1" href="#介绍"><span class="icon icon-link"></span></a>介绍</h3><div class="wrap-body">
|
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="介绍"><a aria-hidden="true" tabindex="-1" href="#介绍"><span class="icon icon-link"></span></a>介绍</h3><div class="wrap-body">
|
||||||
<p>Curl 是一种在服务器之间传输数据的工具,支持协议,包括 HTTP/FTP/IMAP/LDAP/POP3/SCP/SFTP/SMB/SMTP 等</p>
|
<p>Curl 是一种在服务器之间传输数据的工具,支持协议,包括 HTTP/FTP/IMAP/LDAP/POP3/SCP/SFTP/SMB/SMTP 等</p>
|
||||||
<ul>
|
<ul>
|
||||||
@ -266,6 +266,40 @@
|
|||||||
</span></code></pre>
|
</span></code></pre>
|
||||||
<!--rehype:className=wrap-text -->
|
<!--rehype:className=wrap-text -->
|
||||||
<p>下载一系列文件(输出<code>foo_file1.webp</code>、<code>foo_file2.webp…bar_file1_webp</code>等)</p>
|
<p>下载一系列文件(输出<code>foo_file1.webp</code>、<code>foo_file2.webp…bar_file1_webp</code>等)</p>
|
||||||
|
</div></div></div><div class="wrap h3body-not-exist col-span-3"><div class="wrap-header h3wrap"><h3 id="将输出重定向到文件"><a aria-hidden="true" tabindex="-1" href="#将输出重定向到文件"><span class="icon icon-link"></span></a>将输出重定向到文件</h3><div class="wrap-body">
|
||||||
|
<!--rehype:wrap-class=col-span-3-->
|
||||||
|
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line">$ <span class="token function">curl</span> http://url/file <span class="token operator">></span> <span class="token function">file</span>
|
||||||
|
</span></code></pre>
|
||||||
|
</div></div></div><div class="wrap h3body-not-exist col-span-3"><div class="wrap-header h3wrap"><h3 id="基本认证"><a aria-hidden="true" tabindex="-1" href="#基本认证"><span class="icon icon-link"></span></a>基本认证</h3><div class="wrap-body">
|
||||||
|
<!--rehype:wrap-class=col-span-3-->
|
||||||
|
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line">$ <span class="token function">curl</span> <span class="token parameter variable">--user</span> username:password http://example.com/
|
||||||
|
</span><span class="code-line">$ <span class="token function">curl</span> <span class="token parameter variable">-u</span> username:password http://example.com/
|
||||||
|
</span></code></pre>
|
||||||
|
</div></div></div><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="写入文件而不是标准输出"><a aria-hidden="true" tabindex="-1" href="#写入文件而不是标准输出"><span class="icon icon-link"></span></a>写入文件而不是标准输出</h3><div class="wrap-body">
|
||||||
|
<!--rehype:wrap-class=col-span-2-->
|
||||||
|
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line">$ <span class="token function">curl</span> <span class="token parameter variable">-o</span> <span class="token function">file</span> http://url/file
|
||||||
|
</span><span class="code-line">$ <span class="token function">curl</span> <span class="token parameter variable">--output</span> <span class="token function">file</span> http://url/file
|
||||||
|
</span></code></pre>
|
||||||
|
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="下载头信息"><a aria-hidden="true" tabindex="-1" href="#下载头信息"><span class="icon icon-link"></span></a>下载头信息</h3><div class="wrap-body">
|
||||||
|
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line">$ <span class="token function">curl</span> <span class="token parameter variable">-I</span> url
|
||||||
|
</span><span class="code-line"><span class="token comment"># 显示头信息</span>
|
||||||
|
</span></code></pre>
|
||||||
|
</div></div></div><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="将输出写入名为远程文件的文件"><a aria-hidden="true" tabindex="-1" href="#将输出写入名为远程文件的文件"><span class="icon icon-link"></span></a>将输出写入名为远程文件的文件</h3><div class="wrap-body">
|
||||||
|
<!--rehype:wrap-class=col-span-2-->
|
||||||
|
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line">$ <span class="token function">curl</span> <span class="token parameter variable">-o</span> <span class="token function">file</span> http://url/file
|
||||||
|
</span><span class="code-line">$ <span class="token function">curl</span> <span class="token parameter variable">--output</span> <span class="token function">file</span> http://url/file
|
||||||
|
</span></code></pre>
|
||||||
|
</div></div></div><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="执行远程脚本"><a aria-hidden="true" tabindex="-1" href="#执行远程脚本"><span class="icon icon-link"></span></a>执行远程脚本</h3><div class="wrap-body">
|
||||||
|
<!--rehype:wrap-class=col-span-2-->
|
||||||
|
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line">$ <span class="token function">curl</span> <span class="token parameter variable">-s</span> http://url/myscript.sh
|
||||||
|
</span></code></pre>
|
||||||
|
</div></div></div><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="配置文件"><a aria-hidden="true" tabindex="-1" href="#配置文件"><span class="icon icon-link"></span></a>配置文件</h3><div class="wrap-body">
|
||||||
|
<!--rehype:wrap-class=col-span-2-->
|
||||||
|
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line"><span class="token function">curl</span> <span class="token parameter variable">-K</span> <span class="token function">file</span>
|
||||||
|
</span><span class="code-line"><span class="token comment"># 从文件中读取配置</span>
|
||||||
|
</span><span class="code-line"><span class="token function">curl</span> <span class="token parameter variable">--config</span> <span class="token function">file</span>
|
||||||
|
</span><span class="code-line"><span class="token environment constant">$HOME</span>/.curlrc <span class="token comment"># 类 UNIX 系统中的默认配置文件</span>
|
||||||
|
</span></code></pre>
|
||||||
</div></div></div></div></div></div></div><footer class="footer-wrap"><footer class="max-container">© 2022 Kenny Wang, All rights reserved.</footer></footer><script>
|
</div></div></div></div></div></div></div><footer class="footer-wrap"><footer class="max-container">© 2022 Kenny Wang, All rights reserved.</footer></footer><script>
|
||||||
if(('onhashchange' in window) && ((typeof document.documentMode==='undefined') || document.documentMode==8)) {
|
if(('onhashchange' in window) && ((typeof document.documentMode==='undefined') || document.documentMode==8)) {
|
||||||
window.onhashchange = function () {
|
window.onhashchange = function () {
|
||||||
|
Reference in New Issue
Block a user