I've written a new weatherwidget.sh to get the information form the UKMO mobile site (I think it just covers the UK). I'll post it up here when I get it all working, but I have two issues. The first is that the icon is very small, but it's workable for me at the moment - though it may be worth eventually looking into it. The second is that I'm not getting the Conditions being displayed. Here is an example of my output: Code: Current: -3 Conditions: Light Snow High: -2 Low: -3 Image: /tmp/ywtemp.png Anyone spot the obvious thing I must be missing?
Current: -3 Conditions: Light Snow High: -2 Low: -3 Image: /tmp/ywtemp.png
#!/bin/sh #Arguments: # 1 = Place id - from ukmo website # 2 = output dir url="http://www.metoffice.gov.uk/mobile/" # Your default location here, take it from the Met Office mobile # website. id=${2-"XXXXXX"} out=${3-"/tmp"} post="forecastid=$id" # Get info for day wget --user-agent="" -q -t 1 -T 10 --post-data="$post" -O "$out/ywtemp.htm" "${url}5dayforecastdetail" || { exit 1; } curday=`date "+%a %d %b %y"` eval `awk ' BEGIN { use = 0 } /.h2.'"$curday"'..h2./ { use = 1 } use == 1 && /weathervalues/ { sub("^.*>Temperature: ",""); sub(" .*\\\(", " "); sub(" .*$", ""); high=$1; low=$2; exit } END { printf("high=\"%s\" low=\"%s\"", high, low)}' "$out/ywtemp.htm" ` # Get info specific to time of day curtime=`date +%H`00 if [ $curtime -lt 1200 ]; then curtime=0900 elif [ $curtime -ge 1200 ] && [ $curtime -lt 1500 ]; then curtime=1200 elif [ $curtime -ge 1500 ] && [ $curtime -lt 1800 ]; then curtime=1500 elif [ $curtime -ge 1800 ] && [ $curtime -lt 2100 ]; then curtime=1800 elif [ $curtime -gt 2100 ]; then curtime=2100 fi curday=`date "+%a %d %b %y" | sed 's/ /%20/g'` post="forecastid=$id&detail=$curday" wget --user-agent="" -q -t 1 -T 10 --post-data="$post" -O "$out/ywtemp.htm" "${url}5dayforecastdetail" || { exit 1; } eval `awk ' BEGIN { use = 0 } /Time: '$curtime'/ { use = 1 } use == 1 && /img/ { sub("^.*src=", ""); sub(" alt.*$", ""); img=$0 } use == 1 && /weathervalues/ { sub("^.*weathervalues\">", "") sub(" .*$", "") sub("<br/>Temperature: ","\" temp=\"") wx=$0 exit } END { printf("icon=\"%s\" conditions=\"%s\"", img, wx)}' "$out/ywtemp.htm" ` wget --user-agent="" -q -t 1 -T 10 -O "$out/ywtemp.gif" "${url}${icon}" || { exit 1; } echo "Current: "$temp echo "Conditions: "$conditions echo "High: "$high echo "Low: "$low echo "Image: $out/ywtemp.png"