Skip to content

Instantly share code, notes, and snippets.

@chrisbrownie
Created March 7, 2018 05:38
Show Gist options
  • Save chrisbrownie/c83cddcc08ce879e3e3e26fc3761f8ad to your computer and use it in GitHub Desktop.
Save chrisbrownie/c83cddcc08ce879e3e3e26fc3761f8ad to your computer and use it in GitHub Desktop.
Gets the current Virgin Australia happy hour deals. It's not great but it bloody works and that's all that matters
$HHUrl = "http://happyhour.virginaustralia.com/sale-on"
$page = Invoke-WebRequest -Uri $HHUrl
$flightDivs = $page.ParsedHtml.body.getElementsByClassName('card-flight')
foreach ($flightDiv in $flightDivs) {
New-Object -TypeName PSObject -Property @{
"From" = $flightDiv.getElementsByTagName("h3")[0].innerText.Split("`n")[0].Trim() -replace '\ to', ''
"To" = $flightDiv.getElementsByTagName("h3")[0].innerText.Split("`n")[1].Trim()
"Details" = $flightDiv.getElementsByClassName("details")[0].innerText.Trim()
"Price" = $flightDiv.getelementsByClassName("price")[0].innerText.Split('$')[1].Split('*')[0].Trim()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment