get Tokyo weather from Yahoo
MacのGeekTool で
Desktopにお天気を表示させる。東京限定。
Yahoo から、天気の絵をとってくる sh script。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# yahoo weather | |
# | |
# weather image | |
URL=`curl --silent "http://weather.yahoo.com/japan/tokyo-prefecture/tokyo-1118370/" | \ | |
grep background:url | sed -e "s/.*background:url('//" -e 's/png.*/png/' | grep -v partner-logo` | |
curl --silent -o /tmp/weather.png $URL |
/tmp/weather.png に現在の天気のpngファイルが出力される。
Yahooから、現在の天気をテキストでとってくる sh script。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# yahoo weather | |
# | |
# weather text | |
TEXT_INFO=`curl --silent "http://xml.weather.yahoo.com/forecastrss?p=JAXX0085&u=c" | grep yweather:conditio ` | |
TEXT=`echo $TEXT_INFO | sed -e 's/.*text="//' -e 's/".*//'` | |
TEMP=`echo $TEXT_INFO | sed -e 's/.*temp="//' -e 's/".*//'` | |
TEMP=`expr $TEMP - 50` | |
DATE=`echo $TEXT_INFO | sed -e 's/.*date="//' -e 's/".*//'` | |
#echo $TEXT $TEMP "° <BR>" $DATE | |
echo $TEXT ":" $TEMP "C" | |
echo $DATE |
テキストで天気と気温、スナップショット時刻が出力される。
GeekTool で天気の画像を表示させるには、URLに「file://localhost/」を利用。
完成型がこちら。
夜になると、月になる。