Weather report.

Notice: this site was working last week, but now it is disabled. 07/04/2018



My stepfather was into meteorology. In fact, he was a weatherman in the military, He got us into it. So I like to look at a minimal weather report. Batch files make it easier for servers to display data as needed. Have an nslu2 running linux with very low resources. So a batch file is perfect for grabbing data off the web. You can also use it for mobile devices.  That also means you can insert the data grabbed into a database for later research,






Actually I have been doing weather scraping for a while, This is probably almost the tenth script I have written.  From the command line it might look like this:

~$ ./gwp2.sh 22546
The weather for 22546 on Sep 19:
   Updated: 7:05 AM EDT on September 19, 2013
   Observed at Mantico Hill, Beaverdam, Virginia
   Temperature         47.8°F / 8.8°C
   Humidity            98%
   Dew Point           47°F / 8°C
   Windchill           48°F / 9°C
   Wind Gust           0.0 mph / 0.0 km/h
   Pressure            30.19 in / 1022 hPa (Rising)
   Conditions          Mostly Cloudy
   Visibility          10.0 miles / 16.1 kilometers
   UV                  0.0 out of 16
   Clouds              Mostly Cloudy (BKN) : 5500 ft / 1676 m
   Yesterday's Maximum 74°F / 23°C
   Yesterday's Minimum 49°F / 9°C
   Sunrise             6:55 AM EDT
   Sunset              7:11 PM EDT
   Moon Rise           7:09 PM EDT
   Moon Set            7:01 AM EDT
   Moon Phase          Moon Phase
                       Full Moon
   Raw METAR           METAR KEZF 191055Z AUTO 00000KT 10SM BKN055 10/10 A3019 RMK AO2 T00950095

~$ 

The script to grab the data is fairly straight forward.  You pull the whole page off the web and then extract data as needed.

[code]
zip=$1
tmon=$(date +"%b")
tday=$(date +"%d")
echo "The weather for $zip on $tmon $tday:"
lynx -width 1000 -dump "http://m.wund.com/cgi-bin/findweather/getForecast?brand=mobile&query=$zip" > weather
cat weather | grep "Updated"
cat weather | grep "Observed"
cat weather | grep "Temperature"
cat weather | grep "Humidity"
cat weather | grep " Dew Point"
cat weather | grep "Wind" | head -1
cat weather | grep "Wind Gust" | head -1
cat weather | grep "Pressure"
cat weather | grep "Conditions" | head -1
cat weather | grep "Visibility"
cat weather | grep "UV"
cat weather | grep "Clouds"
cat weather | grep "Yesterday's Maximum"
cat weather | grep " Yesterday's Minimum"
cat weather | grep "Sunrise"
cat weather | grep "Sunset"
cat weather | grep "Moon Rise"
cat weather | grep "Moon Set"
cat weather | grep -A1 "Moon Phase"
cat weather | grep "Raw METAR"
[/code]

Note on arch linux use he -a argument on all the grep commands. example:

cat weather | grep -a "Raw METAR"

Hope this litte program helps someone.

-----------------------------------------------------------------------------

Server version: (cgi-bin)

zip=$1
tmon=$(date +"%b")
tday=$(date +"%d")
echo  "The weather for $zip on $tmon $tday:"
lynx -width 1000 -dump  "http://m.wund.com/cgi-bin/findweather/getForecast?brand=mobile&query=$zip" > /tmp/weather
cat /tmp/weather | grep "Updated"
cat /tmp/weather | grep "Observed"
cat /tmp/weather | grep "Temperature"
cat /tmp/weather | grep "Humidity"
cat /tmp/weather | grep " Dew Point"
cat /tmp/weather | grep "Wind" | head -1
cat /tmp/weather | grep "Wind Gust" | head -1
cat /tmp/weather | grep "Pressure"
cat /tmp/weather | grep "Conditions"  | head -1
cat /tmp/weather | grep "Visibility"
cat /tmp/weather | grep "UV"
cat /tmp/weather | grep "Clouds"
cat /tmp/weather | grep "Yesterday's Maximum"
cat /tmp/weather | grep "Yesterday's Minimum"
cat /tmp/weather | grep "Sunrise"
cat /tmp/weather | grep "Sunset"
cat /tmp/weather | grep "Moon Rise"
cat /tmp/weather | grep "Moon Set"
cat /tmp/weather | grep -A1 "Moon Ph
cat /tmp/weather | grep "Raw METAR"


Comments

Popular posts from this blog

Guiless?

MSOffice vs Libreoffice

Raspberry pi zero.