#!/bin/bash
## Yahoo weather forcast extraction
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
## MA 02110-1301, USA
## Credit to Pawel "azhag" Sadkowski <azhag@fluxboxpl.org>
## Pogodynka 0.4
## http://pogodynka.fluxboxpl.org/
## from whom most of this code is borrowed.
## robz
# URL taken from browser address bar, change to suit your location.
SITE="http://weather.yahoo.com/england/cheshire/\
macclesfield-28094/;_ylt=AsQsIG9SbtnVsg.9RWa1feeLYDIB?unit=c"
# you might need to apt-get this
BROWSER=w3m
FILE=/tmp/yahooweather.tmp
$BROWSER -dump $SITE | \
sed -re '/^(\s+)?$/d;s/^(\s+)(.*)/\2/g;s/ °C/°/g;s/°/°C/g;' |\
grep -A19 'Current' > $FILE
xterm -geometry 40x15 -T \
'WEATHER' -e "\
echo '30 Seconds of weather......';\
echo 'Forcast for `date +%A`';\
echo $(sed -n '1p' $FILE | sed 's/Current c/C/g');\
echo $(sed -n '2p' $FILE);\
echo 'Temperature: '$(sed -n '19p' $FILE);\
echo 'Feels Like: '$(sed -n '4p' $FILE);\
echo 'Range: '$(sed -n '20p' $FILE);\
echo 'Pressure: '$(sed -n '6p' $FILE | sed 's/,//g;s/\...//g');\
echo 'Visability: '$(sed -n '10p' $FILE);\
echo 'Wind Dir/Spd: '$(sed -n '14p' $FILE | sed 's/km\/h/kph/g');\
echo 'Humidity: '$(sed -n '8p' $FILE);\
echo 'Dewpoint: '$(sed -n '12p' $FILE);\
echo 'Sunrises @ '$(sed -n '16p' $FILE | sed 's/ AM//g');\
echo 'Sunsets @ '$(sed -ne '18p' $FILE | sed 's/ PM//g' |\
awk -F ':' '{print $1+12":"$2}');\
echo -n 'Is quite enough!......';\
tput civis;\
sleep 30"
rm $FILE
No comments:
Post a Comment