Created
May 28, 2014 14:05
-
-
Save rchaganti/f296becb397f29b27131 to your computer and use it in GitHub Desktop.
Get Python download MSI object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Test-Url { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory=$true)] | |
[String] $Url, | |
[Parameter()] | |
[Switch] $ReturnUri | |
) | |
Process { | |
if ([system.uri]::IsWellFormedUriString($Url,[System.UriKind]::Absolute)) { | |
$true | |
} else { | |
$false | |
} | |
} | |
} | |
$Msi = @() | |
$doc = Invoke-WebRequest -Uri 'https://www.python.org/downloads' | |
foreach ($href in ($doc.links.href -ne '')) { | |
if ((Test-Url -Url $href) -and $href.EndsWith('.msi')) { | |
$uri = [System.uri]$href | |
$Msi += New-Object -TypeName PSObject -Property @{ | |
"Url" = $href | |
"Version" = $Uri.Segments[-2].Replace('/','') | |
} | |
} | |
} | |
$Msi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment