{"id":280,"date":"2014-06-30T13:18:29","date_gmt":"2014-06-30T13:18:29","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=280"},"modified":"2014-06-30T13:18:29","modified_gmt":"2014-06-30T13:18:29","slug":"%e4%bd%bf%e7%94%a8curl%e5%91%bd%e4%bb%a4%e8%8e%b7%e5%8f%96%e7%bd%91%e7%ab%99web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%b1%bb%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/280.html","title":{"rendered":"\u4f7f\u7528Curl\u547d\u4ee4\u83b7\u53d6\u7f51\u7ad9Web\u670d\u52a1\u5668\u7c7b\u578b"},"content":{"rendered":"<h3><span style=\"color: #ff0000; font-family: \u5b8b\u4f53; font-size: medium;\"><span style=\"color: #ff0000;\">\u4f7f\u7528Curl\u547d\u4ee4\u83b7\u53d6\u7f51\u7ad9Web\u670d\u52a1\u5668\u7c7b\u578b<\/span><\/span><\/h3>\n<div>\n<p style=\"color: #333333;\">Curl\u662f\u4e00\u6b3e\u7528\u4e8e\u5728\u7f51\u7edc\u4e0a\u4f20\u8f93\u6570\u636e\u7684\u5de5\u5177\uff0c\u652f\u6301HTTP, HTTPS, FTP, FTPS, TFTP, DICT,TELNET,LDAP\u7b49\u534f\u8bae\u3002\u901a\u8fc7curl\u4f60\u65e2\u53ef\u4ee5\u5c06\u670d\u52a1\u5668\u7684\u6570\u636e\u4e0b\u8f7d\u4e0b\u6765\uff0c\u4e5f\u53ef\u4ee5\u5c06\u672c\u5730\u7684\u6570\u636e\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u3002curl\u7684\u9009\u9879\u5f88\u591a\uff0c\u5927\u5bb6\u53ef\u4ee5\u81ea\u884c\u53c2\u8003curl manual\u3002<\/p>\n<h6 style=\"color: #333333;\">curl\u6700\u7b80\u5355\u7684\u7528\u6cd5\uff0c\u83b7\u53d6\u4e00\u4e2a\u7f51\u7ad9\u9875\u9762\u7684\u6e90\u4ee3\u7801\uff1a<\/h6>\n<div class=\"codeblock\" style=\"color: #333333;\">[root@crazyof ~]# curl www.baidu.com<br \/>\n&lt;HTML&gt;&lt;HEAD&gt;&lt;meta http-equiv=&#8221;content-type&#8221; content=&#8221;text\/html;charset=utf-8&#8243;&gt;<br \/>\n&#8230;<\/div>\n<div class=\"codeblock\" style=\"color: #333333;\">&#8230;<\/p>\n<hr \/>\n<\/div>\n<p style=\"color: #333333;\"><span style=\"color: #ff0000; font-size: medium;\">\u8a00\u5f52\u6b63\u4f20\uff0c\u4e0b\u9762\u5c06\u544a\u8bc9\u5927\u5bb6\u5982\u4f55\u4f7f\u7528-Is\u9009\u9879\u6765\u83b7\u53d6\u7f51\u7ad9\u7684web\u670d\u52a1\u5668\u7c7b\u578b\uff1a<br \/>\n<\/span><\/p>\n<pre class=\"lang:default decode:true\">-I\u00a0:\u83b7\u53d6\u7f51\u7ad9\u7684HTTP-header\u4fe1\u606f\n-s\u00a0:\u9759\u9ed8\u6a21\u5f0f\uff0c\u4e0d\u663e\u793a\u8fdb\u5ea6\u53ca\u9519\u8bef\u4fe1\u606f\n--connect-timeout :\u8bbe\u7f6e\u8fde\u63a5\u8d85\u65f6\u79d2\u6570<\/pre>\n<div class=\"codeblock\" style=\"color: #333333;\">root@crazyof:~# curl -I www.163.com<br \/>\nHTTP\/1.1 200 OK<br \/>\nExpires: Mon, 30 Jun 2014 13:12:21 GMT<br \/>\nDate: Mon, 30 Jun 2014 13:11:01 GMT<br \/>\nServer: nginx<br \/>\nContent-Type: text\/html; charset=GBK<br \/>\nTransfer-Encoding: chunked<br \/>\nVary: Accept-Encoding,User-Agent,Accept<br \/>\nCache-Control: max-age=80<br \/>\nX-Via: 1.1 zib237:8080 (Cdn Cache Server V2.0), 1.1 dls19:4 (Cdn Cache Server V2.0)<br \/>\nConnection: keep-alive<\/div>\n<h6 class=\"codeblock\" style=\"color: #333333;\">\u9996\u5148\u521b\u5efa\u4e00\u4e2asite.txt\u6587\u672c\u6587\u4ef6\uff0c\u5185\u5bb9\u4e3a\u76f8\u5e94\u7684\u7f51\u7ad9\u5730\u5740\uff1a<\/h6>\n<div class=\"codeblock\" style=\"color: #333333;\"><span style=\"color: #800000;\">root@crazyof:~#\u00a0head -10 site.txt<\/span><br \/>\nwww.google.com<br \/>\nwww.baidu.com<br \/>\nyoua.baidu.com<br \/>\npost.baidu.com<br \/>\nhi.baidu.com<br \/>\nwww.sogou.com<br \/>\nwww.youdao.com<br \/>\nwww.soso.com<br \/>\nwww.sohu.com<br \/>\nwww.sina.com<\/div>\n<h6 class=\"codeblock\" style=\"color: #333333;\">\u4e4b\u540e\u7ed3\u5408\u4e0b\u9762\u7684curl.sh\u811a\u672c\uff0c\u5c31\u53ef\u4ee5\u83b7\u77e5site.txt\u4e2d\u7f51\u7ad9\u7684\u670d\u52a1\u5668\u7c7b\u578b\u4e86\uff1a<\/h6>\n<div class=\"codeblock\" style=\"color: #333333;\">\n<pre class=\"lang:default decode:true\">#!\/bin\/bash\nIIS=0\nnginx=0\napache=0\nother=0\nif [ ! -f site.txt ]; then\necho \"ERROR:site.txt NOT exists!\"\nexit 1\nfi\ntotal=`wc -l site.txt|awk '{print $1}'`\nfor website in `cat site.txt`\ndo\nserver=`curl -Is --connect-timeout\u00a015\u00a0$website|awk -F\": \" '\/^Server:\/{print $2}'`\necho -e $website\":\" $server\nif echo $server|grep -i \"IIS\"&gt;\/dev\/null\nthen IIS=`expr $IIS + 1`\nelif echo $server|grep -i \"Apache\"&gt;\/dev\/null\nthen Apache=`expr $Apache + 1`\nelif echo $server|grep -i\u00a0\"nginx\"&gt;\/dev\/null\nthen nginx=`expr $nginx + 1`\nelse other=`expr $other + 1`\nfi\ndone\necho \"--------------------------------------------\"\necho -e \"Total\/tApache\/tIIS\/tnginx\/tother\"\necho -e \"$total\/t$Apache\/t$IIS\/t$nginx\/t$other\"\necho -e \"100%\/t\"`echo \"scale=5;$Apache\/$total*100\"|bc|cut -c1-5`\"%\/t\"`echo \"scale=5;$IIS\/$total*100\"|bc|cut -c1-5`\"%\/t\"`echo \"scale=5;$nginx\/$total*100\"|bc|cut -c1-5`\"%\/t\"`echo \"scale=5;$other\/$total*100\"|bc|cut -c1-5`\"%\/t\"\necho \"--------------------------------------------\"\nexit 0<\/pre>\n<\/div>\n<h6 style=\"color: #333333;\">\u8f93\u51fa\u7ed3\u679c\uff1a<\/h6>\n<div class=\"codeblock\" style=\"color: #333333;\">\n<pre class=\"lang:default decode:true\">root@crazyof:~# bash curl.sh\nwww.google.com: gws\nwww.baidu.com: BWS\/1.1\nyoua.baidu.com: Apache\npost.baidu.com: apache 2.7.18.0\nhi.baidu.com: apache 1.1.26.0\nwww.sogou.com: Apache\nwww.youdao.com: nginx\nwww.soso.com: SWS\/1.0\nwww.sohu.com: SWS\nwww.sina.com: Apache\/2.0.54 (Unix)\nwww.ifeng.com: DnionOS\/1.0\nwww.alibaba.com: Apache\/2.0.59 (Unix) mod_AliCookie(for apache2.x)\/1.1 aliBeacon\/1.0 mod_jk\/1.2.25\nwww.163.com: nginx\nwww.126.com: Apache\nwww.263.com: Microsoft-IIS\/6.0\nwww.tom.com: Apache\nwww.qq.com: nginx\/0.6.39\nqzone.qq.com: Apache\nwww.hotmail.com: Microsoft-IIS\/6.0\nwww.wordpress.com: nginx\nmail.163.com: Apache\nmail.sina.com: Apache\/2.2.9 (FreeBSD) mod_ssl\/2.2.9 OpenSSL\/0.9.7e-p1 PHP\/5.2.6 with Suhosin-Patch\nmail.tom.com: Apache\/1.3.41 (Unix)\nblog.sina.com: nginx\/0.7.62\nblog.sohu.com: nginx\nblog.163.com: nginx\nblog.hexun.com: Microsoft-IIS\/6.0\nwww.hackbase.com: Microsoft-IIS\/6.0\nwww.mydrivers.com: Microsoft-IIS\/6.0\nwww.enet.com.cn: Apache\nwww.cnzz.com: Apache\/2.2.4 (Unix) PHP\/5.2.4\nwww.soufun.com: BIG-IP\nwww.chinaz.com: Microsoft-IIS\/6.0\nwww.51la.com: nginx\/0.6.35\nwww.download.com: Apache\/2.2\nwww.godaddy.com: Microsoft-IIS\/6.0\nwww.answers.com: Apache\nwww.sourceforge.net: BigIP\nwww.gmail.com: gws\nwww.msn.com: Microsoft-IIS\/6.0\nwww.cctv.com: Apache\nwww.xinhuanet.com: Apache\nwww.renren.com: nginx\/0.7.64\nwww.kaixin001.com: Apache\nwww.hao123.com: lighttpd\nwww.114la.com: Apache\nwww.douban.com: nginx\nwww.wikimedia.com: Apache\/1.3 (Unix) mod_ssl\/2.8.28 OpenSSL\/0.9.8f AuthPG\/1.3 FrontPage\/5.0.2.2635\nwww.jiangmin.com: DnionOS\/1.0\nwww.rising.com.cn: Microsoft-IIS\/6.0\nwww.kaspersky.com: nginx\/0.8.15\nwww.kingsoft.com: Apache\/2.0.53\nwww.avast.com: Apache\nwww.360.cn: Apache\nwww.micropoint.com.cn: Apache\nwww.free-av.com: Apache\nwww.avg.com: Apache\nwww.hexun.com: nginx\nwww.eastmoney.com: Microsoft-IIS\/6.0\nwww.chinahr.com: Microsoft-IIS\/6.0\nwww.51job.com: Apache\/2.2.8 (Unix) PHP\/5.2.5\nwww.zhaopin.com: Apache\/1.3.37 (Unix)\nwww.taobao.com: Apache\nwww.paipai.com: nginx\nwww.dangdang.com: nginx\/0.6.37\nwww.youku.com: Apache\nwww.tudou.com: tws\/0.1\nwww.ku6.com: Apache\n6.cn: nginx\/0.6.14\nwww.cntv.cn: Apache\nmedia.17173.com: Apache\nwww.gougou.com: Apache\/2.2.8 (Unix) mod_fastcgi\/2.4.6\nwww.xunlei.com: nginx\/0.7.62\nwww.verycd.com: Apache\nwww.pps.tv: PPStream\nwww.tianya.cn: Microsoft-IIS\/5.0\ndzh.mop.com: Resin\/3.0.19\nwww.pconline.com.cn: nginx\nwww.zol.com.cn: Apache\nwww.pcpop.com: Microsoft-IIS\/6.0\nwww.it168.com: Microsoft-IIS\/6.0\nwww.newhua.com: Microsoft-IIS\/6.0\nwww.skycn.com: Apache\nwww.crsky.com: Microsoft-IIS\/6.0\nwww.csdn.net: CWS\/1.0.64\nwww.chinaitlab.com: Microsoft-IIS\/6.0\nwww.51.com: Apache\nwww.58.com: Microsoft-IIS\/6.0\nwww.jiayuan.com: nginx\/0.7.62\nwww.marry5.com: Apache\nwww.icbc.com.cn: Microsoft-IIS\/6.0\nwww.abchina.com: Microsoft-IIS\/7.5\nwww.ccb.com: Apache\nwww.boc.cn: Microsoft-IIS\/7.0\nwww.bankcomm.com: IBM_HTTP_SERVER\nwww.ebay.com: Apache-Coyote\/1.1\nwww.myspace.com: Microsoft-IIS\/7.5\nwww.aol.com: Apache-Coyote\/1.1\nwww.cnn.com: Apache\nwww.reuters.com: Apache\nwww.wto.org: Microsoft-IIS\/6.0\nwww.who.org: nginx\/0.6.35\nwww.gov.cn: Apache\nwww.court.gov.cn: Apache\/2.0.52 (CentOS)\nwww.moe.edu.cn: Apache\/2.0.54 (Unix) mod_jk2\/2.0.4\nwww.mps.gov.cn: IBM_HTTP_Server\/6.0.2.23 Apache\/2.0.47 (Win32)\nwww.most.gov.cn: Microsoft-IIS\/6.0\nwww.pbc.gov.cn: Microsoft-IIS\/6.0\nwww.moh.gov.cn: Apache\/2.0.59 (Win32)\nwww.ccnt.gov.cn: Microsoft-IIS\/6.0\nwww.mof.gov.cn: Apache\/2.0.59 HP-UX_Apache-based_Web_Server (Unix) DAV\/2\nwww.mod.gov.cn: Apache\nwww.microsoft.com: Microsoft-IIS\/7.5\nwww.microsoft.com.cn: Microsoft-IIS\/7.0\nwww.centos.org: Apache\/2.0.52 (CentOS)\nwww.redhat.com: Apache\nwww.ubuntu.com: Apache\/2.2.8 (Ubuntu) mod_python\/3.3.1 Python\/2.5.2 PHP\/5.2.4-2ubuntu5.9 with Suhosin-Patch mod_ssl\/2.2.8 Ope\nnSSL\/0.9.8g\nwww.gentoo.org: Apache\nwww.debian.org: Apache\/2.2.9 (Debian) mod_ssl\/2.2.9 OpenSSL\/0.9.8g\nwww.novell.com: Apache\nwww.slackware.com: Apache\/1.3.27 (Unix) PHP\/4.3.1\nwww.opensuse.org: Apache\/2.2.10 (Linux\/SUSE)\nwww.wikipedia.org: Apache\nwww.hp.com: Apache\nwww.dell.com: Microsoft-IIS\/7.0\nwww.hitachi.com: Apache\/2.2.11 (Unix) mod_ssl\/2.2.11 OpenSSL\/0.9.7d\nwww.toshiba.com: Sun-ONE-Web-Server\/6.1\nwww.nokia.com: \"Nokia\"\nwww.sony.com: Apache\nwww.intel.com: IA Web Server\/1.0\nwww.amd.com: AkamaiGHost\nwww.nvidia.com: Microsoft-IIS\/6.0\nwww.sun.com: Sun-Java-System-Web-Server\/7.0\nwww.ibm.com: IBM_HTTP_Server\n--------------------------------------------\nTotal\u00a0\u00a0 Apache\u00a0 IIS\u00a0\u00a0\u00a0\u00a0 nginx\u00a0\u00a0 other\n134\u00a0\u00a0\u00a0\u00a0 64\u00a0\u00a0\u00a0\u00a0\u00a0 30\u00a0\u00a0\u00a0\u00a0\u00a0 19\u00a0\u00a0\u00a0\u00a0\u00a0 21\n100%\u00a0\u00a0\u00a0 47.76%\u00a0 22.38%\u00a0 14.17%\u00a0 15.67%\n--------------------------------------------<\/pre>\n<p><span style=\"line-height: 1.5;\">\u7edf\u8ba1\u7684\u7ed3\u679c\uff0c\u4f3c\u4e4e\u548c\u5b9e\u9645\u4f7f\u7528\u60c5\u51b5\u8fd8\u6709\u4e9b\u76f8\u8fd1\u3002\u662f\u4e0d\u662f\u5f88\u7b80\u5355\uff1f<\/span><\/p>\n<p><span style=\"color: #ff0000;\"><strong>\u8bf4\u660e<\/strong><\/span>\uff1a\u811a\u672c\u7684\u5185\u5bb9\u5e76\u4e0d\u590d\u6742\uff0c\u539f\u7406\u4e5f\u5c31\u662f\u901a\u8fc7curl\u7684-I\u9009\u9879\u83b7\u53d6\u7f51\u7ad9\u8fd4\u56de\u7684\u5934\u90e8\u4fe1\u606f\uff0c\u7136\u540e\u901a\u8fc7\u5339\u914d\u51fa\u201cServer\u201d\u6807\u5fd7\u7684\u90a3\u4e00\u884c\u8fdb\u884c\u5faa\u73af\u7edf\u8ba1\uff0c\u6700\u540e\u7ed9\u51fa\u4e2a\u7ed3\u679c\u3002\u6211\u6d4b\u8bd5\u7684\u65f6\u5019\u811a\u672c\u6709\u4e9b\u95ee\u9898\uff0c\u6682\u65f6\u4e5f\u6ca1\u6709\u65f6\u95f4\u8fdb\u884c\u4fee\u6b63\uff0c\u4e0d\u8fc7\u601d\u8def\u65e2\u7136\u6709\u4e86\u81ea\u5df1\u4fee\u6539\u8d77\u6765\u4e5f\u4f1a\u5f88\u5feb\u7684\uff0c\u800c\u4e14\u53ef\u4ee5\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\u5b66\u4e60\/\u590d\u4e60awk\u3001grep\u3001bc\u3001cut\u7b49\u547d\u4ee4\u7684\u4f7f\u7528\uff0c\u6bd4\u8f83\u597d\u73a9+\u6709\u610f\u4e49\u3002<\/p>\n<\/div>\n<h6 style=\"color: #333333;\">\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<p style=\"color: #333333;\"><a href=\"http:\/\/blog.csdn.net\/kozazyh\/article\/details\/5366305\" target=\"_blank\">http:\/\/blog.csdn.net\/kozazyh\/article\/details\/5366305<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528Curl\u547d\u4ee4\u83b7\u53d6\u7f51\u7ad9Web\u670d\u52a1\u5668\u7c7b\u578b Curl\u662f\u4e00\u6b3e\u7528\u4e8e\u5728\u7f51\u7edc\u4e0a\u4f20\u8f93\u6570\u636e\u7684\u5de5\u5177\uff0c\u652f\u6301HTTP, HTTPS [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,12],"tags":[83,84,30],"class_list":["post-280","post","type-post","status-publish","format-standard","hentry","category-linux","category-tools","tag-bash","tag-curl","tag-linux"],"views":5537,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=280"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/280\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}