小编Cha*_*ter的帖子

PowerShell - 从URL中下载不包含文件名的文件

我四处搜寻并尝试了一些事情并没有让它发挥作用.该链接将是例如:( http://www.website com/file/[fileID]例如http://www.website com/file/1wA5fT)并且将出现是否保存文件的框.

我已经尝试过这个,从我能记住的东西,它没有用.

$source = "http://www.website.com/file/[fileID]"
$dest = "C:\Users\Charles\Desktop\Downloads\"

$wc = New-Object System.Net.WebClient
$wc.DownloadFile($source, $dest)
Run Code Online (Sandbox Code Playgroud)

编辑:

如果我为目的地放置文件名,我能够正确下载文件.但是我需要从例如提取文件名

<a href="http://www.website.com/file/[fileID]">Filename.txt</a></li></div></ul>

在我得到这个单挑后,我如何将文件名单输入$ Filename?

$source = "http://www.website.com/file/[fileID]"
$dest = "C:\Users\Charles\Desktop\Downloads\$Filename"

$wc = New-Object System.Net.WebClient
$wc.DownloadFile($source, $dest)
Run Code Online (Sandbox Code Playgroud)

这段代码就可以了.

windows powershell download

3
推荐指数
2
解决办法
2万
查看次数

标签 统计

download ×1

powershell ×1

windows ×1