PI PROJECTS: Weather App
What is it?
This project combines a Python Parser and Weather information pulled down from Yahoo Weather page. A Parser is the process of analysing a string of symbols.
Python Weather App - Looping
Weather App writing to Text File
Install the Parser Module
In the LX Terminal :
Update your Pi
Sudo apt-get update
Upgrade your Pi
Sudo apt-get upgrade
Search for the python Parser in the repositories,
Sudo apt-cache search feed parser
Install the Parser
sudo apt-get install python-feedparser
First go to the Yahoo Weather Website and enter the location where you want to draw the weather data from, eg London.
In the address bar there will be a 5 digit number that denotes the ID of the location, for example London is http://uk.weather.yahoo.com/united-kingdom/england/london-44418/, ID number 44418, you will need the ID number for your own location.
The basic code function is
where the temperature is return in either 'c' Celsius or 'f' Fahrenheit then add the code
d = feedparser.parse(rss_link)
Next use the Parser to pull down the required data, this is stored in categories which are listed at the Yahoo developer site. For example,
atmosphere = d.feed.yweather_atmosphere
This pulls down the related related data from the atmosphere category from this the humidity value can be selected and stored,
humidity = atmosphere['humidity']
Then use the print function to display the data
print "Humidity for "+city, humidity
Program examples for London Weather:
Program 1 -Original program with looping feature
Program 2 - Weather data is written to a text file called weather_summary
Further development details can be found at Yahoo Developer