Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Querying Temperatures through the WUnderground API with PowerShell
#Get weather data from wunderground
#Just an example
#scriptjunkie 2017
#Public domain
#https://www.wunderground.com/history/airport/KJAC/2017/1/24/DailyHistory.html?req_city=Jackson+Hole&req_state=WY&req_statename=Wyoming&reqdb.zip=83012&reqdb.magic=5&reqdb.wmo=99999&format=1
$startdate = Get-Date
$highs = New-Object System.Collections.ArrayList
$lows = New-Object System.Collections.ArrayList
0..365 | %{
$d = $startdate.AddDays(-$_)
$y = $d.Year
$m = $d.Month
if(($m -gt 4) -and ($m -lt 9)){ # this was just my filter to only show temperatures from the skiing season
break
}
$dd = $d.Day
"$y/$m/$dd"
$c = (Invoke-RestMethod "https://www.wunderground.com/history/airport/KJAC/$y/$m/$dd/DailyHistory.html?req_city=Jackson+Hole&req_state=WY&req_statename=Wyoming&reqdb.zip=83012&reqdb.magic=5&reqdb.wmo=99999&format=1").Substring(1) | ConvertFrom-Csv
$low = 1000
$high = -1000
$c | %{
$t = [double]$_.TemperatureF
if ($t -lt $low) {
$low = $t
}
if ($t -gt $high) {
$high = $t
}
}
$highs.Add($high)
$lows.Add($low)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.