I'm starting now using python and I want to create a weather script. Then I'll put that script working with a 16x2 LCD, but that will be easy.
Moving on... I picked up a python program already made by raspberrypi-spy that used to work with Google API. Since google closed that API support I'd seached for another one and found Foreca.
I've managed to put it working with the script, but the problem is that the script is only made to show the temperature and I also want to show the weather condition (Overcast, Clear, Rain, etc) and I can't put this working...
So, the script I've picked up is here. Is the weather_lcd.py file.
And my code is this one:
Code: Select all
# Getting weather stats
import urllib2
import re
weatherURL1 = "http://aaltohtml5name.foreca.com/aaltohtml5-oct12a/data.php?l=102735943&products=cc"
response1 = urllib2.urlopen(weatherURL1)
html1 = response1.read()
#print html
r_temp = re.compile("tf=\"[0-9]{1,3}\"")
r_cond = re.compile("sT=\"[A-Z]{1,20}\"")
temp_search = r_temp.search(html1)
cond_search = r_cond.search(html1)
if temp_search:
temp1 = temp_search.group(0)
temp1 = re.sub("\D", "", temp1)
print temp1+"ºC"
else:
print "no temp found"
if cond_search:
cond = cond_search.group(0)
cond = re.sub("\S", "", cond)
print cond
else:
print "no cond found"By the way (only one more thing), after this I'll want to have it showing a 3 day forecast from here but I also don't know how to search the info from different lines
Sorry for the very very long post. I only want to give you the most info I can.