首先将所有网址保存在一个.txt文件中,类似于这样:
接着
代码如下:
$client = New-Object System.Net.WebClient
$urlArray = Get-Content -Path "这里写上.txt文件的地址.txt"
$downloadDirectory ='这里下载到电脑的哪里'
foreach ($url in $urlArray) {
# 提取文件名部分
$fileName = [System.IO.Path]::GetFileName($url)
# 拼接完整的目标路径
$targetPath = Join-Path $downloadDirectory $fileName
# 下载文件
$client.DownloadFile($url, $targetPath)
Write-Host "Downloaded: $($url) to $($targetPath)"
}