powershell 我如何才能从它的网站与powersell的最新版本的Cura的下载URL?

hgqdbh6s  于 2022-12-13  发布在  Shell
关注(0)|答案(2)|浏览(150)

我想找到下载URL的最新版本的Cura现在它是(https://github.com/Ultimaker/Cura/releases/download/5.2.1/Ultimaker-Cura-5.2.1-win64.exe),我已经写了(Invoke-WebRequest -Uri "https://ultimaker.com/software/ultimaker-cura").innerHTML -match "(https*.exe)"我尝试了.innerHTML或usebasicparsing或Invoke-Restmethod,我找不到它,有人能帮我找到它吗?谢谢提前

8i9zcol2

8i9zcol21#

我建议你使用GitHub的发布API来找到软件的最新版本。

$response = Invoke-RestMethod -Uri "https://api.github.com/repos/Ultimaker/Cura/releases/latest"
$windowsRelease = $response.assets | Where-Object { $_.name -match "win64" }

请注意,我在这里应用Where-Object是为了只过滤掉win64,因为一个发行版可以包含针对不同平台的二进制文件。
然后,您可以使用browser_download_url属性获取下载url,您可以将其与Invoke-WebRequest一起使用来下载它

# download the file
Invoke-WebRequest $windowsRelease.browser_download_url -OutFile "CuraLatest.exe"
o2g1uqev

o2g1uqev2#

日安
当我尝试从Powershell下载文件时,我使用以下命令:

$source = "https://github.com/Ultimaker/Cura/releases/download/5.2.1/Ultimaker-Cura-5.2.1-win64.exe"
$destination = "your download folder path"

#Using Webclient
$wc = [System.Net.WebClient]::new()
$wc.DownloadFile($source,$destination)

这是一种使用.Net下载文件的简单方法

相关问题