有没有办法在Windows中安装cURL,以便从命令提示符运行cURL命令?


当前回答

如果您不喜欢Cygwin,您可以使用本地Windows构建。有些在这里:curl下载向导。

其他回答

从这里安装git命令行。当你在windows中安装git时,你会自动得到curl。您可以使用curl—version检查已安装的curl版本。

这是一个示例curl请求,它发送一个JSON对象中的字符串并对其进行编码。

卷曲https://api.base62.io/encode \ ——请求POST \ ——header "Content-Type: application/json" \ ——data '{"data": "Hello world!"} '

如果你使用Chocolatey包管理器,你可以通过从命令行或PowerShell运行这个命令来安装cURL:

choco install curl

如果您下载它,它应该工作得很好 ——http://curl.haxx.se/dlwiz/?type=bin&os=Win64&flav=MinGW64——FOR 64BIT Win7/XP或from http://curl.haxx.se/dlwiz/?type=bin&os=Win32&flav=-&ver=2000%2FXP——FOR 32BIT Win7/XP只需将文件解压到c:/Windows并从cmd中运行

C:\Users\WaQas>curl -v google.com
* About to connect() to google.com port 80 (#0)
*   Trying 173.194.35.105...
* connected
* Connected to google.com (173.194.35.105) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.28.1
> Host: google.com
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 301 Moved Permanently
< Location: http://www.google.com/
< Content-Type: text/html; charset=UTF-8
< Date: Tue, 05 Feb 2013 00:50:57 GMT
< Expires: Thu, 07 Mar 2013 00:50:57 GMT
< Cache-Control: public, max-age=2592000
< Server: gws
< Content-Length: 219
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< X-Cache: MISS from LHR-CacheMARA3
< X-Cache-Lookup: HIT from LHR-CacheMARA3:64003
< Connection: close
<
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
* Closing connection #0

更新:Curl现在包含在Windows中,不需要通过PowerShell运行它。

首先需要下载cURL可执行文件。对于Windows 64位,从这里下载,对于Windows 32位,从这里下载 之后,将curl.exe文件保存在C:驱动器上。

要使用它,只需打开命令提示符并输入:

C:\curl http://someurl.com

假设您是游戏新手或由于安全限制而无法安装软件,您可以使用Scoop来安装curl。从powershell或命令窗口运行以下命令。注意,这里假设您使用的是Powershell v3.0+。

这里的另一个很酷的优点是,它只为当前用户安装软件。

设置执行异常 Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope CurrentUser 安装勺 Iex (new-object net.webclient).downloadstring('https://get.scoop.sh') 安装旋度。您可能会看到关于缺少散列的警告,但应该会看到cURL已成功安装的最终消息 安装旋度 测试curl的安装 curl -L https://get.scoop.sh