{"id":45302,"date":"2024-10-06T21:54:12","date_gmt":"2024-10-06T13:54:12","guid":{"rendered":"https:\/\/server.hk\/cnblog\/45302\/"},"modified":"2024-10-06T21:54:12","modified_gmt":"2024-10-06T13:54:12","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-centos-8-%e4%b8%8a%e5%ae%89%e8%a3%9d%e5%92%8c%e4%bd%bf%e7%94%a8-curl","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/45302\/","title":{"rendered":"\u5982\u4f55\u5728 CentOS 8 \u4e0a\u5b89\u88dd\u548c\u4f7f\u7528 curl"},"content":{"rendered":"<h1 id=\"%e5%a6%82%e4%bd%95%e5%9c%a8-centos-8-%e4%b8%8a%e5%ae%89%e8%a3%9d%e5%92%8c%e4%bd%bf%e7%94%a8-curl-AEkBPTlNFi\">\u5982\u4f55\u5728 CentOS 8 \u4e0a\u5b89\u88dd\u548c\u4f7f\u7528 curl<\/h1>\n<p>\u5728\u73fe\u4ee3\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0c<code>curl<\/code> \u662f\u4e00\u500b\u975e\u5e38\u91cd\u8981\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u5ee3\u6cdb\u7528\u65bc\u8207\u5404\u7a2e\u5354\u8b70\u9032\u884c\u6578\u64da\u50b3\u8f38\u3002\u7121\u8ad6\u662f\u4e0b\u8f09\u6587\u4ef6\u3001\u6e2c\u8a66 API \u9084\u662f\u9032\u884c\u7db2\u7d61\u8abf\u8a66\uff0c<code>curl<\/code> \u90fd\u80fd\u63d0\u4f9b\u5f37\u5927\u7684\u652f\u6301\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 8 \u4e0a\u5b89\u88dd\u548c\u4f7f\u7528 <code>curl<\/code>\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-curl%ef%bc%9f-AEkBPTlNFi\">\u4ec0\u9ebc\u662f curl\uff1f<\/h2>\n<p><code>curl<\/code> \u662f\u4e00\u500b\u7528\u65bc\u50b3\u8f38\u6578\u64da\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u652f\u6301\u591a\u7a2e\u5354\u8b70\uff0c\u5305\u62ec HTTP\u3001HTTPS\u3001FTP \u7b49\u3002\u5b83\u7684\u4e3b\u8981\u7279\u9ede\u662f\u9748\u6d3b\u6027\u548c\u53ef\u64f4\u5c55\u6027\uff0c\u80fd\u5920\u8655\u7406\u5404\u7a2e\u7db2\u7d61\u8acb\u6c42\uff0c\u4e26\u4e14\u53ef\u4ee5\u8207\u5176\u4ed6\u5de5\u5177\u7d50\u5408\u4f7f\u7528\u3002<\/p>\n<h2 id=\"%e5%9c%a8-centos-8-%e4%b8%8a%e5%ae%89%e8%a3%9d-curl-AEkBPTlNFi\">\u5728 CentOS 8 \u4e0a\u5b89\u88dd curl<\/h2>\n<p>\u5728 CentOS 8 \u4e0a\u5b89\u88dd <code>curl<\/code> \u975e\u5e38\u7c21\u55ae\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 <code>dnf<\/code> \u5305\u7ba1\u7406\u5668\u4f86\u9032\u884c\u5b89\u88dd\u3002\u4ee5\u4e0b\u662f\u5177\u9ad4\u6b65\u9a5f\uff1a<\/p>\n<pre><code>sudo dnf install curl<\/code><\/pre>\n<p>\u57f7\u884c\u4e0a\u8ff0\u547d\u4ee4\u5f8c\uff0c\u7cfb\u7d71\u6703\u81ea\u52d5\u4e0b\u8f09\u4e26\u5b89\u88dd <code>curl<\/code> \u53ca\u5176\u4f9d\u8cf4\u9805\u3002\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u6aa2\u67e5 <code>curl<\/code> \u662f\u5426\u5b89\u88dd\u6210\u529f\uff1a<\/p>\n<pre><code>curl --version<\/code><\/pre>\n<p>\u5982\u679c\u5b89\u88dd\u6210\u529f\uff0c\u60a8\u5c07\u770b\u5230 <code>curl<\/code> \u7684\u7248\u672c\u4fe1\u606f\u3002<\/p>\n<h2 id=\"%e4%bd%bf%e7%94%a8-curl-%e7%9a%84%e5%9f%ba%e6%9c%ac%e5%91%bd%e4%bb%a4-AEkBPTlNFi\">\u4f7f\u7528 curl \u7684\u57fa\u672c\u547d\u4ee4<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u958b\u59cb\u4f7f\u7528 <code>curl<\/code> \u9032\u884c\u5404\u7a2e\u64cd\u4f5c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u898b\u7684\u7528\u6cd5\u793a\u4f8b\uff1a<\/p>\n<h3 id=\"1-%e7%8d%b2%e5%8f%96%e7%b6%b2%e9%a0%81%e5%85%a7%e5%ae%b9-AEkBPTlNFi\">1. \u7372\u53d6\u7db2\u9801\u5167\u5bb9<\/h3>\n<p>\u8981\u7372\u53d6\u67d0\u500b\u7db2\u7ad9\u7684 HTML \u5167\u5bb9\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>curl https:\/\/www.example.com<\/code><\/pre>\n<p>\u9019\u5c07\u986f\u793a\u8a72\u7db2\u7ad9\u7684 HTML \u4ee3\u78bc\u3002<\/p>\n<h3 id=\"2-%e4%b8%8b%e8%bc%89%e6%96%87%e4%bb%b6-AEkBPTlNFi\">2. \u4e0b\u8f09\u6587\u4ef6<\/h3>\n<p>\u5982\u679c\u60a8\u60f3\u4e0b\u8f09\u4e00\u500b\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>-O<\/code> \u53c3\u6578\uff1a<\/p>\n<pre><code>curl -O https:\/\/www.example.com\/file.zip<\/code><\/pre>\n<p>\u9019\u5c07\u628a\u6587\u4ef6\u4e0b\u8f09\u5230\u7576\u524d\u76ee\u9304\u4e0b\uff0c\u4e26\u4fdd\u6301\u539f\u6709\u7684\u6587\u4ef6\u540d\u3002<\/p>\n<h3 id=\"3-%e7%99%bc%e9%80%81-post-%e8%ab%8b%e6%b1%82-AEkBPTlNFi\">3. \u767c\u9001 POST \u8acb\u6c42<\/h3>\n<p>\u8981\u767c\u9001 POST \u8acb\u6c42\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>-d<\/code> \u53c3\u6578\uff1a<\/p>\n<pre><code>curl -X POST -d \"param1=value1&amp;param2=value2\" https:\/\/www.example.com\/api<\/code><\/pre>\n<p>\u9019\u5c07\u5411\u6307\u5b9a\u7684 API \u767c\u9001 POST \u8acb\u6c42\uff0c\u4e26\u651c\u5e36\u53c3\u6578\u3002<\/p>\n<h3 id=\"4-%e6%b7%bb%e5%8a%a0%e6%a8%99%e9%a0%ad-AEkBPTlNFi\">4. \u6dfb\u52a0\u6a19\u982d<\/h3>\n<p>\u5982\u679c\u9700\u8981\u6dfb\u52a0\u81ea\u5b9a\u7fa9\u6a19\u982d\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>-H<\/code> \u53c3\u6578\uff1a<\/p>\n<pre><code>curl -H \"Authorization: Bearer YOUR_TOKEN\" https:\/\/www.example.com\/api<\/code><\/pre>\n<p>\u9019\u5728\u8abf\u7528\u9700\u8981\u8eab\u4efd\u9a57\u8b49\u7684 API \u6642\u975e\u5e38\u6709\u7528\u3002<\/p>\n<h2 id=\"%e7%b5%90%e8%ab%96-AEkBPTlNFi\">\u7d50\u8ad6<\/h2>\n<p>\u5728 CentOS 8 \u4e0a\u5b89\u88dd\u548c\u4f7f\u7528 <code>curl<\/code> \u662f\u4e00\u500b\u7c21\u55ae\u800c\u6709\u6548\u7684\u904e\u7a0b\u3002\u7121\u8ad6\u60a8\u662f\u958b\u767c\u8005\u9084\u662f\u7cfb\u7d71\u7ba1\u7406\u54e1\uff0c<code>curl<\/code> \u90fd\u80fd\u5e6b\u52a9\u60a8\u66f4\u8f15\u9b06\u5730\u9032\u884c\u7db2\u7d61\u8acb\u6c42\u548c\u6578\u64da\u50b3\u8f38\u3002\u901a\u904e\u672c\u6587\u63d0\u4f9b\u7684\u57fa\u672c\u547d\u4ee4\uff0c\u60a8\u53ef\u4ee5\u958b\u59cb\u63a2\u7d22 <code>curl<\/code> \u7684\u5f37\u5927\u529f\u80fd\u3002<\/p>\n<p>\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u7db2\u7d61\u670d\u52d9\uff0c\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u4f86\u63d0\u5347\u60a8\u7684\u61c9\u7528\u6027\u80fd\u548c\u7a69\u5b9a\u6027\u3002\u7121\u8ad6\u662f\u642d\u5efa\u7db2\u7ad9\u9084\u662f\u904b\u884c\u61c9\u7528\uff0c<a href=\"https:\/\/server.hk\">\u9999\u6e2f\u670d\u52a1\u5668<\/a> \u90fd\u80fd\u70ba\u60a8\u63d0\u4f9b\u53ef\u9760\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u5728 CentOS 8 \u4e0a\u5b89\u88dd\u548c\u4f7f\u7528 curl\uff0c\u5feb\u901f\u7372\u53d6\u548c\u50b3\u8f38\u6578\u64da\u7684\u547d\u4ee4\u884c\u5de5\u5177\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-45302","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=45302"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45302\/revisions"}],"predecessor-version":[{"id":45303,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45302\/revisions\/45303"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=45302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=45302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=45302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}