Windows下安裝使用curl命令

本機環境

Windows 7

 

方法/步驟

1、進入網站

https://curl.haxx.se/download/?C=M;O=D網站

2、根據自己的操作系統位數和是否需要SSL下載相應的版本。

這裏下載curl-7.33.0-win64-ssl-sspi.zip,下載完成之後解壓到需要使用curl命令的目錄。這裏爲了方便我先直接解壓到當前目錄。

wKioL1cPdn_yMnUvAAF57hPQxaI487.png


wKiom1cPdcfQ_8saAABgDegr2b4246.png

3、在本窗口下打開運行該命令

【沒有建立系統環境變量,所以只能在本目錄下運行】,檢測是否可以正常運行

wKiom1cPdciw-phZAABVMl-NKpg216.png

注意:

         想得到上面的“在此處打開命令窗口(W)”,請使用鍵盤 Shift+鼠標右鍵 即可

 

wKioL1cPdoCQ2ihTAABuUXyq8UM685.png

C:\common_command>curl -v -X OPTIONS https://www.baidu.com/ 
*Adding handle: conn: 0x205e100
*Adding handle: send: 0
*Adding handle: recv: 0
*Curl_addHandleToPipeline: length: 1
* -Conn 0 (0x205e100) send_pipe: 1, recv_pipe: 0
*About to connect() to www.baidu.com port 443 (#0)
*   Trying 220.181.112.244...
* Connectedto www.baidu.com (220.181.112.244) port 443 (#0)
*SSLv3, TLS handshake, Client hello (1):
*SSLv3, TLS handshake, Server hello (2):
*SSLv3, TLS handshake, CERT (11):
*SSLv3, TLS alert, Server hello (2):
* SSLcertificate problem: unable to get local issuer certificate
*Closing connection 0
curl:(60) SSL certificate problem: unable to get local issuer certificate
Moredetails here: http://curl.haxx.se/docs/sslcerts.html
 
curlperforms SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CAcerts). If the default
 bundle file isn't adequate, you can specify analternate file
 using the --cacert option.
Ifthis HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verificationprobably failed due to a
 problem with the certificate (it might beexpired, or the name might
 not match the domain name in the URL).
Ifyou'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
 
C:\common_command>

4、加入系統環境變量

wKioL1cPdoCB4vh-AAEariMrFRM014.png

wKiom1cPdcmSfyERAABmN29lbWg804.png

用戶變量和系統變量的區別:

         答: 用戶變量:指在該用戶登錄後該環境變量有效。

              系統變量:指任何用戶登錄該系統,該環境變量都有效。

           怎麼使用:判斷該環境變量是否敏感或者是否有用戶限制,如果沒有則配置在系統變量;否則請根據敏感度或者限制情況配置在用戶的環境變量,有利於安全。

 

wKioL1cPdoGjFZ8cAACJox4vms0305.png

wKiom1cPdcmRv6dzAACIg0oacUc551.png

5、在其他路徑下測試是否可以使用CURL命令

wKioL1cPdoHB9jMFAADhAjWo5mU688.png

成功!

 

 

6、該命令常用作用

答:

1、用於查看該網站可以允許有哪些http請求  【常用:GET, HEAD, POST,PUT, DELETE, OPTIONS

         我們經常不希望有PUTDELETE請求,如果有則需要關閉;因爲容易造成一些安全問題。

[zhang@zhang ~]$ curl -v -X OPTIONS https://www.aliyun.com/
*About to connect() to www.aliyun.com port 443 (#0)
*   Trying 42.156.220.114... connected
*Connected to www.aliyun.com (42.156.220.114) port 443 (#0)
*Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSLconnection using TLS_RSA_WITH_AES_128_CBC_SHA
*Server certificate:
*       subject: CN=*.aliyun.com,O="Alibaba(China) Technology Co., Ltd.",L=HangZhou,ST=ZheJiang,C=CN
*       start date: 12月 14 10:47:07 2015 GMT
*       expire date: 12月 14 10:39:17 2016 GMT
*       common name: *.aliyun.com
*       issuer: CN=GlobalSign OrganizationValidation CA - G2,O=GlobalSign nv-sa,C=BE
>OPTIONS / HTTP/1.1
>User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
>Host: www.aliyun.com
>Accept: */*
> 
<HTTP/1.1 200 OK
<Date: Thu, 14 Apr 2016 05:16:27 GMT
<Content-Type: text/html; charset=utf-8
<Transfer-Encoding: chunked
<Connection: close
<Vary: Accept-Encoding
<Server: Tengine
<Vary: Accept-Encoding
<Vary: Accept-Encoding
< Allow: GET
<Strict-Transport-Security: max-age=31536000
<Timing-Allow-Origin: *
< 
 
*Closing connection #0


另請參考:Windows下安裝使用curl命令



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章