2009-03-03 26 views

回答

7

您可以使用powershell脚本来完成此操作。
获取的Web http://www.msn.com/ -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) 
     } 
    } 
} 

http://blogs.msdn.com/mediaandmicrocode/archive/2008/12/01/microcode-powershell-scripting-tricks-scripting-the-web-part-1-get-web.aspx

+0

太棒了!我已将ssh cmd更改为powershell,并且运行良好。 – Pablote 2009-03-03 19:45:57

0

我不记得任何命令行工具。 也许你可以实现类似的使用JavaScript(与WinHttpRequest)的东西,这样的运行它:

wscript your_script.js 

,或只与wget的安装MSYS。

4

我不熟悉Windows上的任何可以执行此操作的命令,但我总是在Windows上为此目的下载GNU wget

1

cURL想到的。

curl -o homepage.html http://www.apptranslator.com/ 

该命令下载页面并将其存储到文件homepage.html中。 提供数千个选项。

0

只需使用Win32 API的(1行的C代码...)

+1

你可以发布哪个API? – 2010-07-02 19:52:26

1

使用BITSAdmin Tool(的bitsadmin是Windows上的命令行实用程序)

例如:

bitsadmin /transfer "Download_Job" /download /priority high "http://www.sourceWebSite.com/file.zip" "C:\destination\file.zip" 

Download_Job - 你想要的任何相关工作名称