简体   繁体   English

在Windows中使用HTML通过cmd文件下载

[英]FIle download via cmd in windows using HTML

I trying to download certain data from a site from cmd of windows. 我试图从Windows的cmd网站上下载某些数据。 When I am downloading via this method, it is generating a firefox window and a pop up which I do not want. 当我通过这种方法下载时,它会生成一个firefox窗口和一个我不想要的弹出窗口。 I should be downloaded to desired folder in background. 我应该在后台下载到所需的文件夹。 I have created an index.HTML file in a directory. 我已经在目录中创建了index.HTML文件。

<!DOCTYPE html>
 <html>
 <script>
 window.location.href = 'http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl?file=gfs.t06z.pgrb2full.0p50.f000&lev_10_m_above_ground=on&var_UGRD=on&var_VGRD=on&subregion=&leftlon=80.6&rightlon=85.4&toplat=25.6&bottomlat=20.1&dir=%2Fgfs.2015060606' ;
</script>
</html>

At cmd I am doing this "start index.HTML" 在cmd,我正在执行此“开始index.HTML”

It is generating a firefox window and save popup which is asking for save permission. 它正在生成一个Firefox窗口并保存弹出窗口,要求获得保存权限。 Is there any way I can do that more smoothly in the background.So that the window doesn't come. 有什么办法可以让我在后台更顺畅地进行操作,以使窗口不会出现。

If you are using Windows and Internet Explorer, you can write a VBScript. 如果使用Windows和Internet Explorer,则可以编写VBScript。 It can be executed from the command line or just be embed in HTML documents. 它可以从命令行执行,也可以嵌入HTML文档中。 You can search stack exchange for some useful VBScripts expamples. 您可以在堆栈交换中搜索一些有用的VBScript示例。

Why do you not use PowerShell? 为什么不使用PowerShell? I don't have access to a Windows machine at the moment, but this should work. 我目前无法使用Windows计算机,但这应该可以工作。

$localFile = "C:\Users\<Username>\Downloads\index.html"
$webClient = New-Object System.Net.WebClient
$urlAddress = "http://example.com/index.html"
$webclient.DownloadFile($url,$localFile)

This will download the data that stored at $urlAddress and store it in $localFile . 这将下载存储在$urlAddress的数据并将其存储在$localFile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM