python-yahoo-weather
python-yahoo-weather copied to clipboard
A simple Python script that uses the Yahoo! RSS weather API.
Python Yahoo Weather
Fetches weather reports from Yahoo! Weather.
Written by Thomas Upton with contributions from Chris Lasher.
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
Example Usage
Default output
$ weather.py 24060
25F and Partly Cloudy
Metric units
$ weather.py -m 24060
-4C and Partly Cloudy
Different delimiter
$ weather.py -d " / " 24060
50F / Mostly Cloudy
With two days' forecast
$ 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
With headers
$ 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