car*_*ing 49 windows command-line-interface wget curl
我来自 Linux/Unix 背景,我一直想知道 Windows 是否有可以从控制台下载文件的二进制文件。
我想自动化某个过程,我的一个要求是不要安装太多软件,而是尽可能多地使用内置的东西。
谢谢!
Rya*_*ies 28
电源外壳。
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($source, $dest)
Run Code Online (Sandbox Code Playgroud)
PS 3.0 中还有 Invoke-WebRequest。
Ste*_*nny 25
Windows 10 包括curl.exe:
https://techcommunity.microsoft.com/t5/containers/-/ba-p/382409
所以你可以做这样的事情:
# example 1
curl.exe --output index.html --url https://superuser.com
# example 2
curl.exe -o index.html https://superuser.com
Run Code Online (Sandbox Code Playgroud)
如果您使用的是较旧的 Windows,您仍然可以下载它:
# example 1
Invoke-WebRequest -OutFile index.html -Uri https://superuser.com
# example 2
iwr -outf index.html https://superuser.com
Run Code Online (Sandbox Code Playgroud)
https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest
use*_*764 12
Windows 中没有类似 wget 的内置命令。您可以通过 Windows PowerShell 使用 .net Framework,如下例所示:
https://superuser.com/questions/362152/native-alternative-to-wget-in-windows-powershell
或者像我一样,在 Windows 上使用 wget:
http://gnuwin32.sourceforge.net/packages/wget.htm
小智 8
我喜欢 http-ping 实用程序。您可以使用以下设置运行:ping 一次并将内容保存到 google.html
http-ping.exe -n 1 http://www.google.com/ -f google.html
Run Code Online (Sandbox Code Playgroud)
它不需要安装。在此处查看有关 http-ping 的更多信息