Run cURL commands from Windows console

2019-01-03 00:46发布

Is there a way to install cURL in Windows in order to run cURL commands from the command prompt?

17条回答
Fickle 薄情
2楼-- · 2019-01-03 01:13

If you use the Chocolatey package manager, you can install cURL by running this command from the command line or from PowerShell:

choco install curl
查看更多
贪生不怕死
3楼-- · 2019-01-03 01:15

I was able to use this site to easily download and install curl on my Windows machine. It took all of 30 seconds. I'm using Windows 7 (w/ Admin privelages), so I downloaded curl-7.37.0-win64.msi from http://curl.haxx.se/download.html.

Also, don't forget to restart your console/terminal after you install curl, otherwise you will get the same error messages.

查看更多
够拽才男人
4楼-- · 2019-01-03 01:20
  1. Visit download page https://curl.haxx.se/download.html - it's incredible
  2. Choose your sytem in list
  3. Don't forget SSL support, it's obvious now, e.g. for https
  4. Unpack curl.exe and .crt to C:\Windows\System32
  5. Restart cmd
  6. Enjoy > curl https://api.stackexchange.com

p.s. If you want another folder to store executable check your paths > echo %PATH%

查看更多
一夜七次
5楼-- · 2019-01-03 01:21

Folks that don't literally need the curl executable, but rather just need to e.g. see or save the results of a GET request now and again, can use powershell directly. From a normal command prompt, type:

powershell -Command "(new-object net.webclient).DownloadString('http://example.com')"

which, while a bit wordy, is similar to typing

curl http://example.com/

in a more Unix-ish environment.

More information about net.webclient is available here: WebClient Methods (System.Net).

UPDATE: I like how ImranHafeez took this one step further in this answer. I'd prefer a simpler cmd-script however, maybe creating a curl.cmd file containing this:

@powershell -Command "(new-object net.webclient).DownloadString('%1')"

which could be called just like the Unix-ish example above:

curl http://example.com/
查看更多
小情绪 Triste *
6楼-- · 2019-01-03 01:21

Install Git for windows Then use git bash to run curl commands.

查看更多
走好不送
7楼-- · 2019-01-03 01:26

From Windows Command Prompt, run curl through Git Bash

"C:\\Users\\sizu\\AppData\\Local\\Programs\\Git\\bin\\sh.exe" --login -i -c "curl https://www.google.com"
查看更多
登录 后发表回答