假設我有一個鏈接 - https://chromedriver.storage.googleapis.com/LATEST_RELEASE 我可以在其中獲取最新的 Chrome 發布版本。我需要檢索此值 (101.0.4951.41) 并將其寫入變數。例如,我創建變數
$LatestChromeRelease = https://chromedriver.storage.googleapis.com/LATEST_RELEASE
所以這個變數的值是'101.0.4951.41'
我可以在我的進一步行動中使用它。
請告知如何在 PowerShell 腳本中實作它。謝謝!
uj5u.com熱心網友回復:
做
$LatestChromeRelease = (wget https://chromedriver.storage.googleapis.com/LATEST_RELEASE).Content
uj5u.com熱心網友回復:
由于給定的端點只回傳版本而不回傳任何其他內容,這只是發送 Web 請求的問題:
$response = Invoke-WebRequest -Uri 'https://chromedriver.storage.googleapis.com/LATEST_RELEASE' -UseBasicParsing
$version = if($response.StatusCode -eq 200){ $response.Content }
如果請求成功,$version現在保存字串值"101.0.4951.41"(或任何當前最新版本號)
uj5u.com熱心網友回復:
使用Invoke-WebRequest
function Get-LatestChromeReleaseVersion{
$Response = Invoke-WebRequest -URI https://chromedriver.storage.googleapis.com/LATEST_RELEASE
return $Response.Content
}
$LatestChromeRelease = Get-LatestChromeReleaseVersion
Write-Host "LatestChromeRelease:" $LatestChromeRelease
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/474161.html
標籤:电源外壳
上一篇:Powershell腳本回傳空白行,正確的輸出行數,但其中沒有
下一篇:PS如何在檔案名中間添加符號
