使用http复制Windows文件

使用http复制Windows文件,windows,command-line,Windows,Command Line,是否有windows命令将文件从http url复制或下载到文件系统?我尝试过copy、xcopy和robocopy,但它们似乎不支持http URL 我不记得有任何命令行实用程序用于此。 也许您可以使用JavaScript(带WinHttpRequest)实现类似的功能,并像这样运行: wscript your_script.js 或者只需使用wget安装msys。我不熟悉Windows上的任何命令,但我总是在Windows上下载用于这些和类似目的。您可以使用powershell脚本来完成此

是否有windows命令将文件从http url复制或下载到文件系统?我尝试过copy、xcopy和robocopy,但它们似乎不支持http URL

我不记得有任何命令行实用程序用于此。 也许您可以使用JavaScript(带WinHttpRequest)实现类似的功能,并像这样运行:

wscript your_script.js

或者只需使用wget安装msys。

我不熟悉Windows上的任何命令,但我总是在Windows上下载用于这些和类似目的。

您可以使用powershell脚本来完成此任务。
获取Web-toFile www.msn.com.html

function Get-Web($url, 
    [switch]$self,
    $credential, 
    $toFile,
    [switch]$bytes)
{
    #.Synopsis
    #    Downloads a file from the web
    #.Description
    #    Uses System.Net.Webclient (not the browser) to download data
    #    from the web.
    #.Parameter self
    #    Uses the default credentials when downloading that page (for downloading intranet pages)
    #.Parameter credential
    #    The credentials to use to download the web data
    #.Parameter url
    #    The page to download (e.g. www.msn.com)    
    #.Parameter toFile
    #    The file to save the web data to
    #.Parameter bytes
    #    Download the data as bytes   
    #.Example
    #    # Downloads www.live.com and outputs it as a string
    #    Get-Web http://www.live.com/
    #.Example
    #    # Downloads www.live.com and saves it to a file
    #    Get-Web http://wwww.msn.com/ -toFile www.msn.com.html
    $webclient = New-Object Net.Webclient
    if ($credential) {
        $webClient.Credential = $credential
    }
    if ($self) {
        $webClient.UseDefaultCredentials = $true
    }
    if ($toFile) {
        if (-not "$toFile".Contains(":")) {
            $toFile = Join-Path $pwd $toFile
        }
        $webClient.DownloadFile($url, $toFile)
    } else {
        if ($bytes) {
            $webClient.DownloadData($url)
        } else {
            $webClient.DownloadString($url)
        }
    }
}
来源

浮现在脑海中

curl -o homepage.html http://www.apptranslator.com/
此命令下载页面并将其存储到文件homepage.html中。 数千个选项可用。

只需使用Win32 api(C中的一行代码…)

使用(bitsadmin是windows上的命令行实用程序)

例如:

bitsadmin /transfer "Download_Job" /download /priority high "http://www.sourceWebSite.com/file.zip" "C:\destination\file.zip"
在哪里,,
下载工作-任何你想要的相关工作名称

太好了!我已将ssh cmd更改为powershell,效果良好。