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


当前回答

对于任何寻找快速解决方案的人,在标准安装cygwin后,但发现curl在win10 x64平台上无法工作:

下载这个退役的存储库,提取它并运行:

git-cmd.bat

效果很好。我假设它有curl的预安装选项。

其他回答

在窗口中创建批处理文件,并在窗口中享受cURL:)

@echo off
echo You are about to use windows cURL, Enter your url after curl command below:
set /p input="curl "
cls
echo %input%
powershell -Command "(new-object net.webclient).DownloadString('%input%')"
pause

转到curl下载向导 选择curl可执行文件 选择“Win32”或“Win64” 然后根据您的要求为它选择包(例如generic/cygwin) 然后你需要选择版本。可以选择“unspecified”。 这将直接带你到下载链接,点击会给你弹出下载压缩文件。 解压压缩文件以获得可执行文件。将这个文件夹添加到环境变量中,就完成了。然后,您可以从cmd执行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!"} '

如果您下载它,它应该工作得很好 ——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

我可以使用这个网站轻松地下载并在我的Windows机器上安装curl。总共花了30秒。我使用Windows 7 (w/ Admin特权),所以我下载了curl-7.37.0-win64。Msi来自http://curl.haxx.se/download.html。

此外,不要忘记在安装curl后重新启动控制台/终端,否则您将得到相同的错误消息。