{"id":7050,"date":"2022-09-01T18:09:21","date_gmt":"2022-09-01T10:09:21","guid":{"rendered":"http:\/\/139.9.1.231\/?p=7050"},"modified":"2022-09-03T14:34:12","modified_gmt":"2022-09-03T06:34:12","slug":"linux_curl","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/09\/01\/linux_curl\/","title":{"rendered":"linux web\u670d\u52a1&#8211; curl"},"content":{"rendered":"\n\n\n<p>     \u6700\u8fd1\u5b9e\u9a8c\u5ba4\u670d\u52a1\u5668\u603b\u662f\u4f1a\u65ad\u7f51\uff0c\u6253\u7b97\u5199\u4e00\u4e2a\u81ea\u52a8\u767b\u5f55\u6821\u56ed\u7f51\u7684\u811a\u672c\uff0c\u7136\u540e\u5c31\u770b\u5230\u4e86\u8fd9\u4e2acurl\u547d\u4ee4\uff0c\u5f53\u7136\u6700\u7ec8\u767b\u5f55\u6821\u56ed\u7f51\u8fd8\u662f\u4f7f\u7528\u7684python request\u5e93\u5b9e\u73b0\u7684\u3002\u987a\u4fbf\u590d\u4e60\u590d\u4e60curl\u7684\u7528\u6cd5\u3002<\/p>\n\n\n\n<p>\u5b98\u7f51: <a href=\"https:\/\/curl.se\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/curl.se\/<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" src=\"https:\/\/pic1.zhimg.com\/v2-18a7712e33cfc87d5aec2f77d2553d58_r.jpg\" alt=\"\" width=\"685\" height=\"513\"\/><\/figure>\n\n\n\n<p>cURL\u65e0\u5904\u4e0d\u5728\u3002\u5b83\u51e0\u4e4e\u9690\u85cf\u5728\u6240\u6709\u8bbe\u5907\u4e2d\uff0c\u4f8b\u5982\u6c7d\u8f66\uff0c\u84dd\u5149\u64ad\u653e\u5668\u7b49\u3002\u5b83\u901a\u8fc7\u4e92\u8054\u7f51\u534f\u8bae\u4f20\u8f93\u4efb\u610f\u7c7b\u578b\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u63ed\u5f00cURL\u795e\u79d8\u547d\u4ee4\u884c\u5de5\u5177\u7684\u9762\u7eb1\uff0c\u89e3\u91ca\u5b83\u662f\u5982\u4f55\u6210\u4e3a\u4e00\u79cd\u901a\u7528\u4ee3\u7801\u7684\uff0c\u5e76\u4e3e\u4f8b\u8bf4\u660e\u5176\u7528\u6cd5\u3002<\/p>\n\n\n\n<h2><strong>cURL\u662f\u4ec0\u4e48\u610f\u601d\uff1f<\/strong><\/h2>\n\n\n\n<p>cURL\uff08\u5ba2\u6237\u7aefURL\uff09\u662f\u4e00\u4e2a\u5f00\u653e\u6e90\u4ee3\u7801\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4e5f\u662f\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684\u5e93\uff08libcurl\uff09\uff0c\u7528\u4e8e\u5728\u670d\u52a1\u5668\u4e4b\u95f4\u4f20\u8f93\u6570\u636e\uff0c\u5e76\u5206\u53d1\u7ed9\u51e0\u4e4e\u6240\u6709\u65b0\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002cURL\u7f16\u7a0b\u7528\u4e8e\u9700\u8981\u901a\u8fc7Internet\u534f\u8bae\u53d1\u9001\u6216\u63a5\u6536\u6570\u636e\u7684\u51e0\u4e4e\u4efb\u4f55\u5730\u65b9\u3002<\/p>\n\n\n\n<p><em>cURL\u652f\u6301\u51e0\u4e4e\u6240\u6709\u7684\u4e92\u8054\u7f51\u534f\u8bae\uff08DICT\uff0cFILE\uff0cFTP\uff0cFTPS\uff0cGOPHER\uff0cHTTP\uff0cHTTPS\uff0cIMAP\uff0cIMAPS\uff0cLDAP\uff0cLDAPS\uff0cMQTT\uff0cPOP3\uff0cPOP3S\uff0cRTMP\uff0cRTMPS\uff0cRTSP\uff0cSCP\uff0cSFTP\uff0cSMB\uff0cSMBS\uff0cSMTP \uff0cSMTPS\uff0cTELNET\u548cTFTP\uff09\u3002<\/em><\/p>\n\n\n\n<p><strong>cURL\u7684\u5386\u53f2<\/strong><\/p>\n\n\n\n<p>\u56de\u523090\u5e74\u4ee3\u7684\u9ed1\u6697\u65f6\u4ee3\uff0c\u90a3\u65f6\u6bcf\u4e2a\u4eba\u4ecd\u7136\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\uff0cDaniel Sterberg\u5e0c\u671b\u5f00\u53d1\u4e00\u4e2a\u7b80\u5355\u7684IRC\u811a\u672c\uff0c\u8be5\u811a\u672c\u53ef\u4ee5\u4e3a\u804a\u5929\u5ba4\u6210\u5458\u8f6c\u6362\u8d27\u5e01\u3002\u57281997\u5e74\uff0c\u5efa\u7acb\u4e92\u8054\u7f51\u534f\u8bae\u6570\u636e\u4f20\u9012\u57fa\u7840\u7684\u65b9\u6cd5\u4e0d\u591a\uff0c\u56e0\u6b64Httpget\uff08\u57fa\u4e8eHTTP\u7684\u4f20\u8f93\u7684\u51e0\u767e\u884c\u4ee3\u7801\uff09\u6210\u4e3acURL\u7684\u8d77\u6e90\u3002\u4e3a\u4e86\u7eaa\u5ff5\u5176\u57fa\u7840\uff0c\u5b83\u7387\u5148\u88ab\u79f0\u4e3aHTTPGET 1.0\u3002<\/p>\n\n\n\n<p>\u51e0\u4e2a\u6708\u540e\uff0c\u5f00\u53d1\u51fa\u4e86FTP\u7684\u652f\u6301\uff0c\u5c31\u4e0d\u5f97\u4e0d\u5220\u9664\u8be5\u540d\u79f0\u4e86\u3002\u73b0\u5728\uff0c\u5b83\u88ab\u79f0\u4e3aurlget 2.0\u3002\u7ecf\u8fc7\u51e0\u6b21\u66f4\u65b0\u540e\uff0c\u57281998\u5e743\u670830\u65e5\uff0c\u540d\u79f0\u518d\u6b21\u66f4\u6539\u4e3a\u73b0\u5728\u4f17\u6240\u5468\u77e5\u7684cURL 3.0\u3002<\/p>\n\n\n\n<p>cURL\u4e4b\u524d\u5176\u5b9e\u8fd8\u6709\u76f8\u4f3c\u7684 wget\u3002\u6211\u4eec\u4e0d\u4f1a\u8fc7\u591a\u4ecb\u7ecd\u7ec6\u8282\uff0c\u4f46\u662fwget\u548ccURL\u4e4b\u95f4\u7684\u4e3b\u8981\u533a\u522b\u5728\u4e8e\u5b83\u4eec\u5404\u81ea\u7684\u4e0b\u8f7d\u529f\u80fd\uff0c\u4f8b\u5982\u524d\u8005\u53ef\u4ee5\u4ece\u4e2d\u65ad\u7684\u4f20\u8f93\u4e2d\u6062\u590d\u5e76\u7ee7\u7eed\u4e0b\u8f7d\u3002<\/p>\n\n\n\n<h2><strong>cURL\u7684\u4f5c\u7528\u662f\u4ec0\u4e48\uff1f<\/strong><\/h2>\n\n\n\n<p class=\"has-bright-blue-background-color has-background\"><strong>cURL\u65e8\u5728\u901a\u8fc7\u4e92\u8054\u7f51\u534f\u8bae\u4f20\u8f93\u6570\u636e\u3002\u5176\u4ed6\u6240\u6709\u5185\u5bb9\u5747\u4e0d\u5728\u5176\u8303\u56f4\u5185\u3002\u5b83\u751a\u81f3\u4e0d\u5904\u7406\u4f20\u8f93\u7684\u6570\u636e\uff0c\u4ec5\u6267\u884c\u4f20\u8f93\u6d41\u7a0b\u3002<\/strong><\/p>\n\n\n\n<p class=\"has-bright-blue-background-color has-background\"><strong>cURL\u53ef\u7528\u4e8e\u8c03\u8bd5\u3002<\/strong>\u4f8b\u5982\u4f7f\u7528\u201c curl -v&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/oxylabs.io\/\" target=\"_blank\">https:\/\/oxylabs.io<\/a>&nbsp;\u201d\u53ef\u4ee5\u663e\u793a\u4e00\u4e2a\u8fde\u63a5\u8bf7\u6c42\u7684\u8be6\u7ec6\u8f93\u51fa\uff0c\u5305\u62ec\u7528\u6237\u4ee3\u7406\uff0c\u63e1\u624b\u6570\u636e\uff0c\u7aef\u53e3\u7b49\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n\n\n\n<p>\u53ef\u5217\u51fa\u548c\u89e3\u91ca\u7684cURL\u547d\u4ee4\u9009\u9879\u592a\u591a\u4e86\u3002\u5e78\u8fd0\u7684\u662f\uff0c\u53ef\u4ee5\u4f7f\u7528\u201c curl \u2013help\u201d\u8fd9\u4e2a\u9009\u9879\uff0c\u5b83\u5217\u51fa\u4e86\u6240\u6709curl\u547d\u4ee4\u884c\u7684\u7528\u6cd5\uff0c\u5e76\u9644\u6709\u7b80\u77ed\u7684\u89e3\u91ca\u6027\u6ce8\u91ca\u3002\u5c3d\u7ba1\u8fd9\u4e9b\u547d\u4ee4\u884c\u7528\u6cd5\u91cc\u6ca1\u6709\u6709\u5173\u5982\u4f55\u4f7f\u7528cURL\u7684\u76f8\u5173\u80cc\u666f\u77e5\u8bc6\u4ecb\u7ecd\uff0c\u7528\u6237\u4e5f\u80fd\u901a\u8fc7\u5217\u8868\u77e5\u9053\u4e00\u4e9b\u547d\u4ee4\u884c\u7684\u7528\u6cd5\u3002<\/p>\n\n\n\n<h3 class=\"has-light-pink-background-color has-background\">\u53ef\u4ee5\u66ff\u4ee3postman\u5de5\u5177\uff01\uff01\uff01<\/h3>\n\n\n\n<p>curl \u662f\u5e38\u7528\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u7528\u6765\u8bf7\u6c42 Web \u670d\u52a1\u5668\u3002\u5b83\u7684\u540d\u5b57\u5c31\u662f\u5ba2\u6237\u7aef\uff08client\uff09\u7684 URL \u5de5\u5177\u7684\u610f\u601d\u3002\u5b83\u7684\u529f\u80fd\u975e\u5e38\u5f3a\u5927\uff0c\u547d\u4ee4\u884c\u53c2\u6570\u591a\u8fbe\u51e0\u5341\u79cd\u3002\u5982\u679c\u719f\u7ec3\u7684\u8bdd\uff0c\u5b8c\u5168\u53ef\u4ee5\u53d6\u4ee3 Postman \u8fd9\u4e00\u7c7b\u7684\u56fe\u5f62\u754c\u9762\u5de5\u5177\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\">1\u3001\u4e0d\u5e26\u6709\u4efb\u4f55\u53c2\u6570\u65f6\uff0ccurl \u5c31\u662f\u53d1\u51fa GET \u8bf7\u6c42\u3002<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl https:\/\/www.example.com\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u5411<code>www.example.com<\/code>\u53d1\u51fa GET \u8bf7\u6c42\uff0c\u670d\u52a1\u5668\u8fd4\u56de\u7684\u5185\u5bb9\u4f1a\u5728\u547d\u4ee4\u884c\u8f93\u51fa\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\">2\u3001<strong>-A<\/strong>\u53c2\u6570\u6307\u5b9a\u5ba2\u6237\u7aef\u7684\u7528\u6237\u4ee3\u7406\u6807\u5934\uff0c\u5373<code>User-Agent<\/code>\u3002curl \u7684\u9ed8\u8ba4\u7528\u6237\u4ee3\u7406\u5b57\u7b26\u4e32\u662f<code>curl\/[version]<\/code>\u3002<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>$ curl -A 'Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/76.0.3809.100 Safari\/537.36' https:\/\/google.com<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u5c06<code>User-Agent<\/code>\u6539\u6210 Chrome \u6d4f\u89c8\u5668\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -A '' https:\/\/google.com<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u4f1a\u79fb\u9664<code>User-Agent<\/code>\u6807\u5934\u3002<\/p>\n\n\n\n<p>\u4e5f\u53ef\u4ee5\u901a\u8fc7<code>-H<\/code>\u53c2\u6570\u76f4\u63a5\u6307\u5b9a\u6807\u5934\uff0c\u66f4\u6539<code>User-Agent<\/code>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -H 'User-Agent: php\/1.0' https:\/\/google.com<\/code><\/pre>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\">3\u3001<strong><code>-b<\/code>\u53c2\u6570\u7528\u6765\u5411\u670d\u52a1\u5668\u53d1\u9001 Cookie<\/strong><\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>$ curl -b 'foo=bar' https:\/\/google.com<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u4f1a\u751f\u6210\u4e00\u4e2a\u6807\u5934<code>Cookie: foo=bar<\/code>\uff0c\u5411\u670d\u52a1\u5668\u53d1\u9001\u4e00\u4e2a\u540d\u4e3a<code>foo<\/code>\u3001\u503c\u4e3a<code>bar<\/code>\u7684 Cookie\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -b 'foo1=bar;foo2=bar2' https:\/\/google.com<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u53d1\u9001\u4e24\u4e2a Cookie\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -b cookies.txt https:\/\/www.google.com<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u8bfb\u53d6\u672c\u5730\u6587\u4ef6<code>cookies.txt<\/code>\uff0c\u91cc\u9762\u662f\u670d\u52a1\u5668\u8bbe\u7f6e\u7684 Cookie\uff08\u53c2\u89c1<code>-c<\/code>\u53c2\u6570\uff09\uff0c\u5c06\u5176\u53d1\u9001\u5230\u670d\u52a1\u5668\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\">4\u3001<strong><code><code>-c<\/code>\u53c2\u6570\u5c06\u670d\u52a1\u5668\u8bbe\u7f6e\u7684 Cookie \u5199\u5165\u4e00\u4e2a\u6587\u4ef6\u3002<\/code><\/strong><\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>$ curl -c cookies.txt https:\/\/www.google.com\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u5c06\u670d\u52a1\u5668\u7684 HTTP \u56de\u5e94\u6240\u8bbe\u7f6e Cookie \u5199\u5165\u6587\u672c\u6587\u4ef6<code>cookies.txt<\/code>\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\">5\u3001<strong><code><code><code>-d<\/code>\u53c2\u6570\u7528\u4e8e\u53d1\u9001 POST \u8bf7\u6c42\u7684\u6570\u636e\u4f53<\/code><\/code><\/strong><\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>$ curl -d'login=emma\uff06password=123'-X POST https:\/\/google.com\/login\n# \u6216\u8005\n$ curl -d 'login=emma' -d 'password=123' -X POST  https:\/\/google.com\/login\n<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528<code>-d<\/code>\u53c2\u6570\u4ee5\u540e\uff0cHTTP \u8bf7\u6c42\u4f1a\u81ea\u52a8\u52a0\u4e0a\u6807\u5934<code>Content-Type : application\/x-www-form-urlencoded<\/code>\u3002\u5e76\u4e14\u4f1a\u81ea\u52a8\u5c06\u8bf7\u6c42\u8f6c\u4e3a POST \u65b9\u6cd5\uff0c\u56e0\u6b64\u53ef\u4ee5\u7701\u7565<code>-X POST<\/code>\u3002<\/p>\n\n\n\n<p><code>-d<\/code>\u53c2\u6570\u53ef\u4ee5\u8bfb\u53d6\u672c\u5730\u6587\u672c\u6587\u4ef6\u7684\u6570\u636e\uff0c\u5411\u670d\u52a1\u5668\u53d1\u9001\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -d '@data.txt' https:\/\/google.com\/login\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u8bfb\u53d6<code>data.txt<\/code>\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u4f5c\u4e3a\u6570\u636e\u4f53\u5411\u670d\u52a1\u5668\u53d1\u9001\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\">6\u3001<strong><code><code><code><code>--data-urlencode<\/code><\/code><\/code><\/code><\/strong><\/h5>\n\n\n\n<p><strong><code>\u53c2\u6570\u7b49\u540c\u4e8e-D\uff0c\u53d1\u9001 POST \u8bf7\u6c42\u7684\u6570\u636e\u4f53\uff0c\u533a\u522b\u5728\u4e8e\u4f1a\u81ea\u52a8\u5c06\u53d1\u9001\u7684\u6570\u636e\u8fdb\u884c URL \u7f16\u7801\u3002<\/code><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ curl --data-urlencode 'comment=hello world' https:\/\/google.com\/login\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u4ee3\u7801\u4e2d\uff0c\u53d1\u9001\u7684\u6570\u636e<code>hello world<\/code>\u4e4b\u95f4\u6709\u4e00\u4e2a\u7a7a\u683c\uff0c\u9700\u8981\u8fdb\u884c URL \u7f16\u7801\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\">7\u3001<strong><code><code><code><code><code>-e<\/code>\u53c2\u6570\u7528\u6765\u8bbe\u7f6e HTTP \u7684\u6807\u5934<code>Referer<\/code>\uff0c\u8868\u793a\u8bf7\u6c42\u7684\u6765\u6e90\u3002<\/code><\/code><\/code><\/code><\/strong><\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -e '<a href=\"https:\/\/google.com\/\">https:\/\/google.com<\/a>?q=example' https:\/\/www.example.com\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u5c06<code>Referer<\/code>\u6807\u5934\u8bbe\u4e3a<code>https:\/\/google.com?q=example<\/code>\u3002<\/p>\n\n\n\n<p><code>-H<\/code>\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u76f4\u63a5\u6dfb\u52a0\u6807\u5934<code>Referer<\/code>\uff0c\u8fbe\u5230\u540c\u6837\u6548\u679c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\ncurl -H 'Referer: <a href=\"https:\/\/google.com\/\">https:\/\/google.com<\/a>?q=example' https:\/\/www.example.com<\/code><\/pre>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\">8\u3001<strong><code><code><code><code><code><code>-F<\/code>\u53c2\u6570\u7528\u6765\u5411\u670d\u52a1\u5668\u4e0a\u4f20\u4e8c\u8fdb\u5236\u6587\u4ef6\u3002<\/code><\/code><\/code><\/code><\/code><\/strong><\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>$ curl -F '<a href=\"mailto:file=@photo.png\">file=@photo.png<\/a>' https:\/\/google.com\/profile\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u4f1a\u7ed9 HTTP \u8bf7\u6c42\u52a0\u4e0a\u6807\u5934<code>Content-Type: multipart\/form-data<\/code>\uff0c\u7136\u540e\u5c06\u6587\u4ef6<code>photo.png<\/code>\u4f5c\u4e3a<code>file<\/code>\u5b57\u6bb5\u4e0a\u4f20\u3002<\/p>\n\n\n\n<p><code>-F<\/code>\u53c2\u6570\u53ef\u4ee5\u6307\u5b9a MIME \u7c7b\u578b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -F '<a href=\"mailto:file=@photo.png\">file=@photo.png<\/a>;type=image\/png' https:\/\/google.com\/profile\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u6307\u5b9a MIME \u7c7b\u578b\u4e3a<code>image\/png<\/code>\uff0c\u5426\u5219 curl \u4f1a\u628a MIME \u7c7b\u578b\u8bbe\u4e3a<code>application\/octet-stream<\/code>\u3002<\/p>\n\n\n\n<p><code>-F<\/code>\u53c2\u6570\u4e5f\u53ef\u4ee5\u6307\u5b9a\u6587\u4ef6\u540d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -F '<a href=\"mailto:file=@photo.png\">file=@photo.png<\/a>;filename=me.png' https:\/\/google.com\/profile\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u4e2d\uff0c\u539f\u59cb\u6587\u4ef6\u540d\u4e3a<code>photo.png<\/code>\uff0c\u4f46\u662f\u670d\u52a1\u5668\u63a5\u6536\u5230\u7684\u6587\u4ef6\u540d\u4e3a<code>me.png<\/code>\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\">9\u3001<strong><code><code><code><code><code><code><code>-G<\/code>\u53c2\u6570\u7528\u6765\u6784\u9020 URL \u7684\u67e5\u8be2\u5b57\u7b26\u4e32<\/code><\/code><\/code><\/code><\/code><\/code><\/strong><\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>$ curl -G -d 'q=kitties' -d 'count=20' https:\/\/google.com\/search\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u4f1a\u53d1\u51fa\u4e00\u4e2a GET \u8bf7\u6c42\uff0c\u5b9e\u9645\u8bf7\u6c42\u7684 URL \u4e3a<code>https:\/\/google.com\/search?q=kitties&amp;count=20<\/code>\u3002\u5982\u679c\u7701\u7565<code>--G<\/code>\uff0c\u4f1a\u53d1\u51fa\u4e00\u4e2a POST \u8bf7\u6c42\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u6570\u636e\u9700\u8981 URL \u7f16\u7801\uff0c\u53ef\u4ee5\u7ed3\u5408<code>--data--urlencode<\/code>\u53c2\u6570\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -G --data-urlencode 'comment=hello world' https:\/\/www.example.com<\/code><\/pre>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\">10\u3001<code>-H<\/code>\u53c2\u6570\u6dfb\u52a0 HTTP \u8bf7\u6c42\u7684\u6807\u5934\u3002<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>$ curl -H 'Accept-Language: en-US' https:\/\/google.com\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u6dfb\u52a0 HTTP \u6807\u5934<code>Accept-Language: en-US<\/code>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -H 'Accept-Language: en-US' -H 'Secret-Message: xyzzy' https:\/\/google.com\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u6dfb\u52a0\u4e24\u4e2a HTTP \u6807\u5934\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -d '{\"login\": \"emma\", \"pass\": \"123\"}' -H 'Content-Type: application\/json' https:\/\/google.com\/login\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u6dfb\u52a0 HTTP \u8bf7\u6c42\u7684\u6807\u5934\u662f<code>Content-Type: application\/json<\/code>\uff0c\u7136\u540e\u7528<code>-d<\/code>\u53c2\u6570\u53d1\u9001 JSON \u6570\u636e\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\">11\u3001<strong><code>-i<\/code>\u53c2\u6570\u6253\u5370\u51fa\u670d\u52a1\u5668\u56de\u5e94\u7684 HTTP \u6807\u5934\u3002<\/strong><\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -i https:\/\/www.example.com\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u6536\u5230\u670d\u52a1\u5668\u56de\u5e94\u540e\uff0c\u5148\u8f93\u51fa\u670d\u52a1\u5668\u56de\u5e94\u7684\u6807\u5934\uff0c\u7136\u540e\u7a7a\u4e00\u884c\uff0c\u518d\u8f93\u51fa\u7f51\u9875\u7684\u6e90\u7801\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\">12\u3001<strong>-I<\/strong><\/h5>\n\n\n\n<p><code>-I<\/code>\u53c2\u6570\u5411\u670d\u52a1\u5668\u53d1\u51fa HEAD \u8bf7\u6c42\uff0c\u7136\u4f1a\u5c06\u670d\u52a1\u5668\u8fd4\u56de\u7684 HTTP \u6807\u5934\u6253\u5370\u51fa\u6765\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -I https:\/\/www.example.com\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u8f93\u51fa\u670d\u52a1\u5668\u5bf9 HEAD \u8bf7\u6c42\u7684\u56de\u5e94\u3002<\/p>\n\n\n\n<p><code>--head<\/code>\u53c2\u6570\u7b49\u540c\u4e8e<code>-I<\/code>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl --head https:\/\/www.example.com\n<\/code><\/pre>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\">13\u3001<strong>-k<\/strong><\/h5>\n\n\n\n<p><code>-k<\/code>\u53c2\u6570\u6307\u5b9a\u8df3\u8fc7 SSL \u68c0\u6d4b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -k https:\/\/www.example.com\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u4e0d\u4f1a\u68c0\u67e5\u670d\u52a1\u5668\u7684 SSL \u8bc1\u4e66\u662f\u5426\u6b63\u786e\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\">14\u3001<strong>-L<\/strong><\/h5>\n\n\n\n<p><code>-L<\/code>\u53c2\u6570\u4f1a\u8ba9 HTTP \u8bf7\u6c42\u8ddf\u968f\u670d\u52a1\u5668\u7684\u91cd\u5b9a\u5411\u3002curl \u9ed8\u8ba4\u4e0d\u8ddf\u968f\u91cd\u5b9a\u5411\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -L -d 'tweet=hi' https:\/\/api.twitter.com\/tweet\n<\/code><\/pre>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\"><strong>15\u3001&#8211;limit-rate<\/strong><\/h5>\n\n\n\n<p><code>--limit-rate<\/code>\u7528\u6765\u9650\u5236 HTTP \u8bf7\u6c42\u548c\u56de\u5e94\u7684\u5e26\u5bbd\uff0c\u6a21\u62df\u6162\u7f51\u901f\u7684\u73af\u5883\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl --limit-rate 200k https:\/\/google.com\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u5c06\u5e26\u5bbd\u9650\u5236\u5728\u6bcf\u79d2 200K \u5b57\u8282\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\">16\u3001<strong>-o<\/strong><\/h5>\n\n\n\n<p><code>-o<\/code>\u53c2\u6570\u5c06\u670d\u52a1\u5668\u7684\u56de\u5e94\u4fdd\u5b58\u6210\u6587\u4ef6\uff0c\u7b49\u540c\u4e8e<code>wget<\/code>\u547d\u4ee4\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -o example.html https:\/\/www.example.com\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u5c06<code>www.example.com<\/code>\u4fdd\u5b58\u6210<code>example.html<\/code>\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\"><strong>17\u3001-O<\/strong><\/h5>\n\n\n\n<p><code>-O<\/code>\u53c2\u6570\u5c06\u670d\u52a1\u5668\u56de\u5e94\u4fdd\u5b58\u6210\u6587\u4ef6\uff0c\u5e76\u5c06 URL \u7684\u6700\u540e\u90e8\u5206\u5f53\u4f5c\u6587\u4ef6\u540d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -O https:\/\/www.example.com\/foo\/bar.html\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u5c06\u670d\u52a1\u5668\u56de\u5e94\u4fdd\u5b58\u6210\u6587\u4ef6\uff0c\u6587\u4ef6\u540d\u4e3a<code>bar.html<\/code>\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\"><strong>18\u3001-s<\/strong><\/h5>\n\n\n\n<p><code>-s<\/code>\u53c2\u6570\u5c06\u4e0d\u8f93\u51fa\u9519\u8bef\u548c\u8fdb\u5ea6\u4fe1\u606f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -s https:\/\/www.example.com\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u4e00\u65e6\u53d1\u751f\u9519\u8bef\uff0c\u4e0d\u4f1a\u663e\u793a\u9519\u8bef\u4fe1\u606f\u3002\u4e0d\u53d1\u751f\u9519\u8bef\u7684\u8bdd\uff0c\u4f1a\u6b63\u5e38\u663e\u793a\u8fd0\u884c\u7ed3\u679c\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u60f3\u8ba9 curl \u4e0d\u4ea7\u751f\u4efb\u4f55\u8f93\u51fa\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -s -o \/dev\/null https:\/\/google.com\n<\/code><\/pre>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\"><strong>19\u3001-S<\/strong><\/h5>\n\n\n\n<p><code>-S<\/code>\u53c2\u6570\u6307\u5b9a\u53ea\u8f93\u51fa\u9519\u8bef\u4fe1\u606f\uff0c\u901a\u5e38\u4e0e<code>-s<\/code>\u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -s -o \/dev\/null https:\/\/google.com\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u6ca1\u6709\u4efb\u4f55\u8f93\u51fa\uff0c\u9664\u975e\u53d1\u751f\u9519\u8bef\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\"><strong>20\u3001 -u<\/strong><\/h5>\n\n\n\n<p><code>-u<\/code>\u53c2\u6570\u7528\u6765\u8bbe\u7f6e\u670d\u52a1\u5668\u8ba4\u8bc1\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -u 'bob:12345' https:\/\/google.com\/login\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u8bbe\u7f6e\u7528\u6237\u540d\u4e3a<code>bob<\/code>\uff0c\u5bc6\u7801\u4e3a<code>12345<\/code>\uff0c\u7136\u540e\u5c06\u5176\u8f6c\u4e3a HTTP \u6807\u5934<code>Authorization: Basic Ym9iOjEyMzQ1<\/code>\u3002<\/p>\n\n\n\n<p>curl \u80fd\u591f\u8bc6\u522b URL \u91cc\u9762\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl https:\/\/bob:12345@google.com\/login\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u80fd\u591f\u8bc6\u522b URL \u91cc\u9762\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u5c06\u5176\u8f6c\u4e3a\u4e0a\u4e2a\u4f8b\u5b50\u91cc\u9762\u7684 HTTP \u6807\u5934\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -u 'bob' https:\/\/google.com\/login\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u53ea\u8bbe\u7f6e\u4e86\u7528\u6237\u540d\uff0c\u6267\u884c\u540e\uff0ccurl \u4f1a\u63d0\u793a\u7528\u6237\u8f93\u5165\u5bc6\u7801\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\"><strong>21\u3001-v<\/strong><\/h5>\n\n\n\n<p><code>-v<\/code>\u53c2\u6570\u8f93\u51fa\u901a\u4fe1\u7684\u6574\u4e2a\u8fc7\u7a0b\uff0c\u7528\u4e8e\u8c03\u8bd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -v https:\/\/www.example.com\n<\/code><\/pre>\n\n\n\n<p><code>--trace<\/code>\u53c2\u6570\u4e5f\u53ef\u4ee5\u7528\u4e8e\u8c03\u8bd5\uff0c\u8fd8\u4f1a\u8f93\u51fa\u539f\u59cb\u7684\u4e8c\u8fdb\u5236\u6570\u636e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl --trace - https:\/\/www.example.com\n<\/code><\/pre>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\"><strong>2<\/strong>2\u3001<strong>-x<\/strong><\/h5>\n\n\n\n<p><code>-x<\/code>\u53c2\u6570\u6307\u5b9a HTTP \u8bf7\u6c42\u7684\u4ee3\u7406\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -x socks5:\/\/james:<a href=\"mailto:cats@myproxy\">cats@myproxy<\/a>.com:8080 https:\/\/www.example.com\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u6307\u5b9a HTTP \u8bf7\u6c42\u901a\u8fc7<code>myproxy.com:8080<\/code>\u7684 socks5 \u4ee3\u7406\u53d1\u51fa\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u6ca1\u6709\u6307\u5b9a\u4ee3\u7406\u534f\u8bae\uff0c\u9ed8\u8ba4\u4e3a HTTP\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -x james:<a href=\"mailto:cats@myproxy\">cats@myproxy<\/a>.com:8080 https:\/\/www.example.com\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u4e2d\uff0c\u8bf7\u6c42\u7684\u4ee3\u7406\u4f7f\u7528 HTTP \u534f\u8bae\u3002<\/p>\n\n\n\n<h5 class=\"has-light-pink-background-color has-background\"><strong>2<\/strong>3\u3001<strong>-X<\/strong><\/h5>\n\n\n\n<p><code>-X<\/code>\u53c2\u6570\u6307\u5b9a HTTP \u8bf7\u6c42\u7684\u65b9\u6cd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ curl -X POST https:\/\/www.example.com\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u547d\u4ee4\u5bf9<code>https:\/\/www.example.com<\/code>\u53d1\u51fa POST \u8bf7\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u5b9e\u9a8c\u5ba4\u670d\u52a1\u5668\u603b\u662f\u4f1a\u65ad\u7f51\uff0c\u6253\u7b97\u5199\u4e00\u4e2a\u81ea\u52a8\u767b\u5f55\u6821\u56ed\u7f51\u7684\u811a\u672c\uff0c\u7136\u540e\u5c31\u770b\u5230\u4e86\u8fd9\u4e2acurl\u547d\u4ee4\uff0c\u5f53\u7136\u6700\u7ec8\u767b\u5f55\u6821\u56ed\u7f51\u8fd8 &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/09\/01\/linux_curl\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">linux web\u670d\u52a1&#8211; curl<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/7050"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=7050"}],"version-history":[{"count":51,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/7050\/revisions"}],"predecessor-version":[{"id":7279,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/7050\/revisions\/7279"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=7050"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=7050"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=7050"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}