For those who like to live in command line and python script to tell you what the weather is like (although if you live on the CL you probably don’t go outside much so it’s pretty irrelevant).
The weather forecast is from Yahoo weather, after entering your locale get the code from the url, for example http://weather.yahoo.com/forecast/UKXX0123.html is Glasgow. The part we are interested in is the code “UKXX0123″.
Save the script as “weather”, make it executable and put in executable directory like /usr/local/bin
Now open a new terminal window and you should get this:
test@testing:~$ weather Current Conditions: Partly Cloudy, 13 C Forecast: Mon - Partly Cloudy. High: 14 Low: 7 Tue - Partly Cloudy. High: 16 Low: 8
Now the code.
#!/usr/bin/env python import feedparser,re feed="http://weather.yahooapis.com/forecastrss?p=YOUR-CODE-HERE&u=c" data=feedparser.parse(feed) pattern='<.+?>' summary=data.entries.summary forecast=re.sub(pattern,'',summary) forecast=re.split('\n',forecast) for line in forecast[0:-2]: print line