Skip to content

Instantly share code, notes, and snippets.

@matt40k
Created August 8, 2016 22:07
Show Gist options
  • Save matt40k/b41c2bc6c64ae010d91e3934c78590d6 to your computer and use it in GitHub Desktop.
Save matt40k/b41c2bc6c64ae010d91e3934c78590d6 to your computer and use it in GitHub Desktop.
# Gets a list of excuses from programmingexcuses.com
$url = 'http://programmingexcuses.com/'
$totalLoopCount = 10
$loopCount = 0
$excuses = @()
Function GetExcuse {
$result = Invoke-WebRequest -Uri $url
$lines = $result.Content.Split("`n")
foreach ($line in $lines) {
if ($line.Contains('<a')) {
$excuse = $line.Replace('</a></center>', '').Replace('<center style="color: #333; padding-top: 200px; font-family: Courier; font-size: 24px; font-weight: bold;">', '').Replace('<a href="/" rel="nofollow" style="text-decoration: none; color: #333;">', '')
Write-Host $excuse
If ($excuses -contains $excuse)
{
}
Else
{
$excuses += $excuse
}
}
}
}
While ($loopCount -le $totalLoopCount) {
GetExcuse
Write-Host $loopCount
$loopCount = $loopCount + 1
}
Write-Host $excuses.Count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment