I would like to insert weather report to my diary automatically, so I googled "weather script python" - yes, I prefer python - and found
a python script fetching weather report from Yahoo! Weather written by
Thomas Upton
In order to use the script, I looked up the location ID for my city. I searched
Yahoo Weather home page. The location ID is in the URL for the forecast page for the city. For example, the forecast page for Los Angeles is
http://weather.yahoo.com/united-states/california/los-angeles-2442047/
. The location ID of Los Angeles is
2442047
.
Unfortunately, the script does not work for me. I checked the python source code, and found the feed URL is "http://xml.weather.yahoo.com/forecastrss?p=", which seems only for US zip code. So I modified the URL to "http://weather.yahooapis.com/forecastrss?w=", which works with the code from
Yahoo Weather home page.
You can apply a patch if you would like, which I supply here:
--- weather.py 2011-02-05 21:40:02.000000000 +0900
+++ weather.py 2011-02-05 21:51:43.000000000 +0900
@@ -19,7 +19,8 @@
# Yahoo!'s limit on the number of days they will forecast
DAYS_LIMIT = 2
-WEATHER_URL = 'http://xml.weather.yahoo.com/forecastrss?p=%s'
+#WEATHER_URL = 'http://xml.weather.yahoo.com/forecastrss?p=%s'
+WEATHER_URL = 'http://weather.yahooapis.com/forecastrss?w=%s'
METRIC_PARAMETER = '&u=c'
WEATHER_NS = 'http://xml.weather.yahoo.com/ns/rss/1.0'