Google's API will accept locations with spaces (e.g. "London, England" instead
of
"London,England"). If you try this, you get:
>>> pywapi.get_weather_from_google('london, england')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pywapi.py", line 51, in get_weather_from_google
handler = urllib2.urlopen(url)
File "/usr/lib/python2.5/urllib2.py", line 124, in urlopen
return _opener.open(url, data)
File "/usr/lib/python2.5/urllib2.py", line 387, in open
response = meth(req, response)
File "/usr/lib/python2.5/urllib2.py", line 498, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.5/urllib2.py", line 425, in error
return self._call_chain(*args)
File "/usr/lib/python2.5/urllib2.py", line 360, in _call_chain
result = func(*args)
File "/usr/lib/python2.5/urllib2.py", line 506, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: Bad Request
If you cal urllib.quote on the location_id before generating the URL, then it
fixes it.
Original issue reported on code.google.com by dan.y.t...@gmail.com on 25 Aug 2009 at 6:09
Original issue reported on code.google.com by
dan.y.t...@gmail.com
on 25 Aug 2009 at 6:09