Fetches weather reports from Yahoo! Weather.
Written by Thomas Upton with contributions from Chris Lasher and [William Schurman] ws.
This code is licensed under a BY-NC-SA Creative Commons license.
See the blog post for more information.
Usage: weather.py [options] location_code
$ weather.py --help
for options and their descriptions.
Weather data can be printed to an output file with the --output
option.
$ weather.py 24060 --output='weather.txt'
If a weather report cannot be generated, the specified output file is not altered. This is useful when attempting to cache weather output while, for instance, on a flaky network connection. To attempt to update the weather file and output its contents, one could use the following command. If the weather could not be loaded, the previous contents of the file are shown.
$ weather.py 24060 --output='weather.txt' && cat weather.txt
$ weather.py 24060
25F and Partly Cloudy
$ weather.py -s
25F and Partly Cloudy
$ weather.py -m 24060
-4C and Partly Cloudy
$ weather.py -d " / " 24060
50F / Mostly Cloudy
$ weather.py -lf2 24060
Blacksburg VA
25F and Partly Cloudy
17 Jan 2009
High: 30F
Low: 22F
Condition: Partly Cloudy
18 Jan 2009
High: 39F
Low: 25F
Condition: PM Snow Showers
$ weather.py -lvf2 24060
Location:
Blacksburg VA
Current conditions:
25F and Partly Cloudy
Forecast:
17 Jan 2009
High: 30F
Low: 22F
Condition: Partly Cloudy
18 Jan 2009
High: 39F
Low: 25F
Condition: PM Snow Showers