fetchweather.frink

View or download fetchweather.frink in plain text format


// Fetch average temperature data for a given weather station.

urlbase = "http://www.weather.com/weather/wxclimatology/daily/USMA0066?climoMonth="

println["mean = new dict"]

for month = 1 to 12
{
   infile = read["$urlbase$month"]
   for [line] = infile =~ %r/<TD\s*[^>]*\s*CLASS="lapAvgDataRow"[^>]*>(.*?)<\/TR>/gs
   {
      line =~ %s/<\/?TD[^>]*>//gs
      line =~ %s/\n\s*/\t/gs
      [day,sunrise,sunset,high,low,mean] = split["\t", line]
      if [t] = mean =~ %r/([\-]?\d+)/
         println["mean@\"$month-$day\" = F[$t]"]
   }
}

println["mean@\"2-29\" = mean@\"2-28\""]
println["\"Ok\""]


View or download fetchweather.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 17645 days, 8 hours, 33 minutes ago.