You are not logged in.
Since weather.com is ending their free XOAP service conkyForecast will no longer work at the end of this month.
Therefore I wrote a small script to get the temperature and condition from Weather Underground
#!/usr/bin/python
#
# Fetches Weather info from Weather Underground
#
# Usage: ./wundergound.py zipcode
#
# International:
# * Go to http://www.wunderground.com/
# * Find your city
# * Click the RSS icon
# * Station ID is the number that follows /stations/ in the url
#
#
# Values are either True or False
metric=False
international=False
import sys
import feedparser
def usage():
print("Usage:")
if international:
print(" ./wunderground.py StationID")
else:
print(" ./weunderground.py zipcode")
sys.exit(1)
if not len(sys.argv) == 2:
usage()
location=sys.argv[1]
if international:
url="http://rss.wunderground.com/auto/rss_full/global/stations/"
else:
url="http://rss.wunderground.com/auto/rss_full/"
feed=feedparser.parse(url+location)
if not feed.feed:
# Assume Error
print("Error")
sys.exit(1)
current=feed['items'][0].title
if metric:
temp=current.split(",")[0].split(":")[1].split("/")[1].strip()
else:
temp=current.split(",")[0].split(":")[1].split("/")[0].strip()
condition=current.split(",")[1].split("-")[0].strip()
print(temp, "-", condition)
Example:
$ ./wunderground 11201
69.6F - Clear
Conky:
${execi 600 /home/pyther/scripts/wunderground 11201}
Enjoy!
Offline
Crap didn't know, glad i spotted this while browsing! Good work!
Offline
Thanks, but Weather Underground not support my location
Offline
So, you, re saying the yaourt packages for conky (conkyforecast and -bzr) are going to become useless? I like this packages!!!.
Offline
conkyforecast-bzr since r66 supports WU (but lacks locale and weather fonts support) which should become the default. You still need a (free) API key.
Offline
Syntax seems to have changed. For those who don't know Python, there are some newer scripts mentioned here: http://kubuntuforums.net/forums/index.p … =3118776.0
Offline
The script works fine but I'd like to modify it a bit. Can anyone point me to a good tutorial on feedparser? I've googled but only found raw guides for programmers.
Offline
Here is the documentation for feedparser: http://packages.python.org/feedparser/
What exactly are you trying to do? In the script feedparser is getting the first rss entry and parsing it.
If you want the afternoon, night, or next day entries...
afternoon=feed['items'][1].title # afternoon
tonight=feed['items'][2].title # Tonight
tomorrow=feed['items'][3].title # tomorrow
Offline
Thanks just what I was looking for!
Offline
Thanks for the script pyther, did anyone modify it for like a 2 or 3 day forecast? Any chance of posting it, thanks.
Cheers
Paul-S
Offline
Working on it ...
Offline