Skip to content

Instantly share code, notes, and snippets.

@scriptjunkie
Created January 25, 2017 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scriptjunkie/10b345a8fb748a7c874296a8653a0f55 to your computer and use it in GitHub Desktop.
Save scriptjunkie/10b345a8fb748a7c874296a8653a0f55 to your computer and use it in GitHub Desktop.
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