Created
May 28, 2014 13:48
-
-
Save rchaganti/c30375210710d5bd3c6a to your computer and use it in GitHub Desktop.
Test a URL!
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 | |
) | |
Process { | |
if ([system.uri]::IsWellFormedUriString($Url,[System.UriKind]::Absolute)) { | |
$true | |
} else { | |
$false | |
} | |
} | |
} | |
#Here is how we use it | |
$doc = Invoke-WebRequest -Uri 'https://www.python.org/downloads' | |
foreach ($href in ($doc.links.href -ne '')) { | |
if (Test-Url -Url $href) { | |
$href | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment