Skip to content

Instantly share code, notes, and snippets.

@AndrewPla
Last active September 6, 2019 15:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewPla/5397c72f596233c2c923362d928e6a2c to your computer and use it in GitHub Desktop.
Save AndrewPla/5397c72f596233c2c923362d928e6a2c to your computer and use it in GitHub Desktop.
Get-MmaEvent
function Get-MmaEvent {
<#
.Description
Returns upcoming MMA events from https://www.whenarethefights.com/
#>
$request = Invoke-WebRequest -Uri 'https://www.whenarethefights.com/'
# Only grab the events that have a countdown.
$content = $request.Links.outertext | Where-Object {$_ -like '*days*'}
$content | ForEach-Object {
$lines = ($_).split([Environment]::NewLine) | Where-Object { $_ -notlike '' }
[pscustomobject]@{
Event = $lines[0]
Date = $lines[-1]
Days = $($lines -like '*days')
Hours = $($lines -like '*hours')
Minutes = $($lines -like '*minutes')
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment