Closed GoogleCodeExporter closed 8 years ago
To reproduce, try:
pywapi.get_weather_from_yahoo('VEXX0399', units='metric')
You will get:
*** IndexError: list index out of range
This happens in
http://code.google.com/p/python-weather-api/source/browse/trunk/pywapi.py#264
When trying to do:
weather_data['link'] = dom.getElementsByTagName('link')[0].firstChild.data
When the dom was:
u'<?xml version="1.0" ?><rss version="2.0"
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0">\n<channel>\n<title>Yah
oo! Weather - Error</title>\n<description>Yahoo! Weather
Error</description>\n<item><title>City not found</title><description>\nInvalid
Input /forecastrss?p=VEXX0399&u=c\n</description></item></channel></rss><!--
api28.weather.bf1.yahoo.com Thu Jan 3 20:48:03 PST 2013 -->'
The weird thing is that it is a valid code for a city:
http://www.weather.com/weather/today/San%20Carlos+Venezuela+VEXX0399
Original comment by frap...@ravvit.net
on 3 Jan 2013 at 9:14
It seems Yahoo just plain doesn't have certain cities in their weather database.
What's also odd is that it *is* in their geocoding database:
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.places%20wher
e%20text%3D%22san+carlos+venezuela%22&format=xml
It's the entry with a woeid of 420131.
That said, I suppose it would be better to return an empty result on invalid
location. Alternately, we could have a "response" key in the dictionary that
is returned by each get_weather_from_ method that says "success" or "urlerror"
or "invalid location" based on the response.
Original comment by jtas...@gmail.com
on 9 Mar 2013 at 7:04
This issue was closed by revision r116.
Original comment by jtas...@gmail.com
on 13 Mar 2013 at 10:15
Original issue reported on code.google.com by
5m5.4551...@gmail.com
on 22 Aug 2012 at 10:52