{"id":1350,"date":"2011-08-02T02:23:24","date_gmt":"2011-08-01T18:23:24","guid":{"rendered":"http:\/\/www.jpuyy.com\/blog\/?p=1350"},"modified":"2020-06-05T11:28:25","modified_gmt":"2020-06-05T03:28:25","slug":"curl-usage","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=1350","title":{"rendered":"curl\u5b9e\u6218"},"content":{"rendered":"<p>\u53d6\u5f97\u5934\u4fe1\u606f<\/p>\n<pre>curl --head 127.0.0.1\ncurl -I 127.0.0.1<\/pre>\n<p>\u53d6\u5f97http\u72b6\u6001\u7801\uff08\u52a0<code>-I<\/code>\u53ea\u52a0\u8f7d\u5934\u4fe1\u606f\uff0c\u901f\u5ea6\u66f4\u5feb\uff09<br \/>\n-w\u540e\u52a0\u53d8\u91cf\uff0c\u83b7\u53d6\u5f88\u591a\u4e0e\u8bf7\u6c42\u76f8\u5173\u7684\u989d\u5916\u4fe1\u606f\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\uff0c\u5982%{http_code}\u663e\u793a\u72b6\u6001\u7801\uff0c%{time_total} \u54cd\u5e94\u65f6\u95f4\uff0c %{size_download}\u9875\u9762\u5927\u5c0f\uff0c %{content_type} \u9875\u9762\u7c7b\u578b<\/p>\n<pre>curl -s -o \/dev\/null -w \"%{http_code}\" http:\/\/jpuyy.com\ncurl -s -o \/dev\/null -I -w \"%{http_code}\" http:\/\/jpuyy.com<\/pre>\n<p>\u5982\u679c\u6709\u4e00\u6279url\u9700\u8981\u5224\u65ad\u72b6\u6001\u7801\uff0c\u5199\u5165url_http_status.txt\u4e2d\uff0c\u811a\u672c\u5982\u4e0b\uff1a<\/p>\n<pre>#!\/bin\/bash\nfor i in `cat url_http_status.txt`\ndo\nSTATUS_CODE=`curl -o \/dev\/null -s -w %{http_code} $i`\necho -e \"$i:\\t$STATUS_CODE\"\ndone<\/pre>\n<p>\u4f7f\u7528\u5b89\u9759\u6a21\u5f0f<\/p>\n<pre class=\"p1\">--silent<\/pre>\n<p>curl \u8ddf\u8e2a 301\u8df3\u8f6c\uff0c\u4f7f\u7528\u53c2\u6570 -L<\/p>\n<pre>\u279c  ~  curl -I http:\/\/www.jpuyy.com -L\nHTTP\/1.1 301 Moved Permanently\nServer: nginx\/1.0.15\nDate: Sun, 09 Nov 2014 10:40:15 GMT\nContent-Type: text\/html; charset=UTF-8\nConnection: keep-alive\nX-Powered-By: PHP\/5.3.3\nX-CF-Powered-By: WP 1.3.14\nX-Pingback: http:\/\/jpuyy.com\/xmlrpc.php\nLocation: http:\/\/jpuyy.com\/\n\nHTTP\/1.1 200 OK\nServer: nginx\/1.0.15\nDate: Sun, 09 Nov 2014 10:40:16 GMT\nContent-Type: text\/html; charset=UTF-8\nConnection: keep-alive\nVary: Accept-Encoding\nX-Powered-By: PHP\/5.3.3\nX-CF-Powered-By: WP 1.3.14\nX-Pingback: http:\/\/jpuyy.com\/xmlrpc.php\n<\/pre>\n<p>\u53d6\u5f97\u591a\u4e2a\u5b50\u57df\u540d\u4fe1\u606f<\/p>\n<pre>curl http:\/\/site.{one,two,three}.com\n\u5982\uff1acurl http:\/\/{bbs,ftp,nic}.cczu.edu.cn<\/pre>\n<p>\u4e0b\u8f7dfile1.txt-file100.txt<\/p>\n<pre>ftp:\/\/ftp.numericals.com\/file[1-100].txt\nftp:\/\/ftp.numericals.com\/file[001-100].txt (with leading zeros)\nftp:\/\/ftp.letters.com\/file[a-z].txt\nhttp:\/\/any.org\/archive[1996-1999]\/vol[1-4]\/part{a,b,c}.html\nhttp:\/\/www.numericals.com\/file[1-100:10].txt 10\uff0c20.....txt<\/pre>\n<p>\u5173\u4e8ecookies<\/p>\n<p>The file specified with -b\/&#8211;cookie is only used as input.No cookies will be stored in the file.<\/p>\n<p>\u7528\u4e8e\u8bfb\u5165<\/p>\n<p>To store cookies, use the -c\/&#8211;cookie-jar option or you could even save the HTTP headers to a file using -D\/&#8211;dump-header!<\/p>\n<pre class=\"p1\">curl --cookie \"desktop=1;key2=value2\" -v -o \/dev\/null http:\/\/jpuyy.com\/<\/pre>\n<p>curl\u4f2a\u9020\u5934\u4fe1\u606f<\/p>\n<pre class=\"p1\">curl --header \"X-Forwarded-For:8.8.8.8\" --header \"Accept-Language: en\" http:\/\/www.jpuyy.com<\/pre>\n<p>curl\u6a21\u62df\u6307\u5b9a\u6d4f\u89c8\u5668<\/p>\n<pre>curl -A \"Mozilla\/5.0 (X11; Ubuntu; Linux x86_64; rv:25.0) Gecko\/20100101 Firefox\/25.0\" [URL]<\/pre>\n<p>curl\u6a21\u62df\u6307\u5b9a\u7684referer<\/p>\n<pre>curl [URL] -e http:\/\/www.aavv.com<\/pre>\n<pre class=\"bash\">\u6216\u4f7f\u7528 --referer<\/pre>\n<p>curl\u4f7f\u7528\u538b\u7f29<\/p>\n<pre>curl -I \"http:\/\/www.hao123.com\" --compressed<\/pre>\n<pre>curl -I -H \"Accept-Encoding: gzip, deflate\" \"http:\/\/www.hao123.com\"<\/pre>\n<p>curl\u6267\u884cpost\u63d0\u4ea4<\/p>\n<pre class=\"p1\">curl http:\/\/localhost:8000\/wrap -d text=kadj+kdsj+kasdfj+kaslfdj+jkdasljf+skdfjal-yyyyksdjf-kasjd<\/pre>\n<p>curl \u5e26\u8d26\u53f7\uff0cbasic \u8ba4\u8bc1<\/p>\n<pre class=\"p1\"><span class=\"s1\">-u<\/span>, --<span class=\"s1\">u<\/span>ser &lt;user:password&gt;\n\ncurl -L -i --user myuser:mypass http:\/\/abc.example.com\/manage\n<\/pre>\n<p>curl https\u51fa\u73b0\u9519\u8bef<\/p>\n<pre class=\"p1\">curl -sS https:\/\/getcomposer.org\/installer\ncurl: (60) SSL certificate problem, verify that the CA cert is OK. Details:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed\nMore details here: http:\/\/curl.haxx.se\/docs\/sslcerts.html<\/pre>\n<p class=\"p1\">\u89e3\u51b3\u529e\u6cd5\uff1a<br \/>\nhttp:\/\/curl.haxx.se\/docs\/caextract.html \u4e0b\u8f7d\u0017\u0005 \u0005ca-bundle.crt\u5230 \/etc\/pki\/tls\/certs\/ca-bundle.crt<\/p>\n<p>curl \u6307\u5b9a\u4ee3\u7406\u670d\u52a1\u5668<\/p>\n<pre>curl http:\/\/jpuyy.com -x 211.61.47.19:80<\/pre>\n<p>\u6307\u5b9a socks5 \u4ee3\u7406\u670d\u52a1\u5668<\/p>\n<pre>curl --socks5 127.0.0.1:1081 jpuyy.com\/ip.php<\/pre>\n<p>\u66f4\u591a\u6848\u4f8b\uff1ahttp:\/\/www.thegeekstuff.com\/2012\/04\/curl-examples\/<\/p>\n<p>\u4e0b\u8f7d github release tar.gz \u5305<\/p>\n<pre>curl -L -O https:\/\/github.com\/ansible\/ansible\/archive\/v2.1.0.0-0.2.rc2.tar.gz<\/pre>\n<p>\u83b7\u53d6 token\uff0c\u5148\u51c6\u5907\u4e00\u4e2a\u8ba4\u8bc1\u6587\u4ef6 auth.json<\/p>\n<pre>{\n\"username\":\"jpuyy\",\n\"password\":\"pass\"\n}\n<\/pre>\n<p>\u53d1\u9001\u8bf7\u6c42<\/p>\n<pre>curl -v -XPOST info.mysite.com\/api\/auth\/token -d @auth.json -H 'Content-Type: application\/json'\n<\/pre>\n<p>\u6839\u636e\u8ba4\u8bc1\u7684 token \u653e\u5728 header \u8bbf\u95ee<\/p>\n<pre>curl info.mysite.com\/api\/config\/web.gui-H \"Authorization: FuZzA2In0...\"<\/pre>\n<p>curl \u8fd4\u56de \u0005000 \u72b6\u6001\u7801\u8868\u793a\u8d85\u65f6<\/p>\n<p>curl \u6d4b\u8bd5 websocket<\/p>\n<pre>curl -i -N -H \"Connection: Upgrade\" -H \"Upgrade: websocket\" -H \"Host: echo.websocket.org\" -H \"Origin: http:\/\/www.websocket.org\" http:\/\/echo.websocket.org<\/pre>\n<p>curl \u4e0b\u8f7d\u65ad\u70b9\u91cd\u8fde<\/p>\n<pre>curl -O -C - http:\/\/jpuyy.com\/a.txt\n<\/pre>\n<p>curl \u81ea\u5df1\u6307\u5b9a\u57df\u540d\u7684\u89e3\u6790<\/p>\n<pre>--resolve [DOMAIN]:[PORT]:[IP]\ncurl https:\/\/jpuyy.com --resolve jpuyy.com:443:192.168.1.66\n<\/pre>\n<p>curl \u91cd\u590d\u8bf7\u6c42 100\u6b21<\/p>\n<pre>curl 'https:\/\/jpuyy.com\/abc?[1-100]'\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u53d6\u5f97\u5934\u4fe1\u606f curl &#8211;head 127.0.0.1 curl -I 127.0.0.1 \u53d6\u5f97http\u72b6\u6001\u7801\uff08\u52a0-I\u53ea\u52a0\u8f7d\u5934\u4fe1\u606f\uff0c\u901f\u5ea6\u66f4\u5feb\uff09 -w\u540e\u52a0\u53d8\u91cf\uff0c\u83b7\u53d6\u5f88\u591a\u4e0e\u8bf7\u6c42\u76f8\u5173\u7684\u989d\u5916\u4fe1\u606f\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\uff0c\u5982%{http_code}\u663e\u793a\u72b6\u6001\u7801\uff0c%{time_total} \u54cd\u5e94\u65f6\u95f4\uff0c %{size_download}\u9875\u9762\u5927\u5c0f\uff0c %{content_type} \u9875\u9762\u7c7b\u578b curl -s -o \/dev\/null -w &#8220;%{http_code}&#8221; http:\/\/jpuyy.com curl -s -o \/dev\/null -I -w &#8220;%{http_code}&#8221; http:\/\/jpuyy.com \u5982\u679c\u6709\u4e00\u6279url\u9700\u8981\u5224\u65ad\u72b6\u6001\u7801\uff0c\u5199\u5165url_http_status.txt\u4e2d\uff0c\u811a\u672c\u5982\u4e0b\uff1a #!\/bin\/bash for i in `cat url_http_status.txt` do STATUS_CODE=`curl -o \/dev\/null -s -w %{http_code} $i` echo -e &#8220;$i:\\t$STATUS_CODE&#8221; done \u4f7f\u7528\u5b89\u9759\u6a21\u5f0f &#8211;silent curl \u8ddf\u8e2a 301\u8df3\u8f6c\uff0c\u4f7f\u7528\u53c2\u6570 -L \u279c ~ [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64],"tags":[],"class_list":["post-1350","post","type-post","status-publish","format-standard","hentry","category-web"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/1350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1350"}],"version-history":[{"count":46,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/1350\/revisions"}],"predecessor-version":[{"id":8982,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/1350\/revisions\/8982"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}