tsroten/yweather

HTTP Error 502: Connection refused

Closed this issue · 9 comments

Hi! I used the python module pywapi to extract weather informations, but when Yahoo changed its API, it didn't work. So I downloaded yweather from git and I launched the command python3 setup.py install inside the directory yweather. After that, I was trying to catch some weather informations about my city and I wrote this code:
import yweather
client = yweather.Client()
result = client.fetch_weather("12798281", metric=True)
print(result)

result = client.fetch_weather("12798281", metric=True)
File "/home/SmartStation/yweather.py", line 180, in fetch_weather
rss = self._fetch_xml(url)
File "/home/SmartStation/yweather.py", line 344, in _fetch_xml
with contextlib.closing(urlopen(url)) as f:
File "/usr/lib/python3.4/urllib/request.py", line 153, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.4/urllib/request.py", line 461, in open
response = meth(req, response)
File "/usr/lib/python3.4/urllib/request.py", line 571, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.4/urllib/request.py", line 499, in error
return self._call_chain(_args)
File "/usr/lib/python3.4/urllib/request.py", line 433, in _call_chain
result = func(_args)
File "/usr/lib/python3.4/urllib/request.py", line 579, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 502: Connection refused
What is the problem? I'm using Python 3.4.3 on my Raspberry PI B+. I couldn't use pip, because pip3 didn't work.

I'm also getting 502 errors recently, although initially all was working fine. Seems to return a woeid ok but fails when I try to fetch_weather. Anyone else had this but got it working again? I've updated to 0.1.1 but this hasn't helped.

I am having the same issues. I can return a woeid fine but it fails whenever I try to fetch_weather. Currently on the newest version.

I solved The problem! Both for Python2.7 and 3...

Well done. What did you do? Looks like we need to do something with OAUTH?

Looks like this will do it. From the Yahoo developer network pages (https://developer.yahoo.com/weather/)
import urllib2, urllib, json baseurl = "https://query.yahooapis.com/v1/public/yql?" yql_query = "select wind from weather.forecast where woeid=2460286" yql_url = baseurl + urllib.urlencode({'q':yql_query}) + "&format=json" result = urllib2.urlopen(yql_url).read() data = json.loads(result) print data['query']['results']

This is The right way! I modified this code a little for Python3.

@tsroten any updates?

@athallas @Hisoka87 Yahoo Weather has discontinued the RSS feed interface this library is based on. There is a new YQL Query interface: https://developer.yahoo.com/weather/ (as mentioned above by @Abolisher)

I don't plan on updating this library to use the new endpoint. Feel free to fork!

@tsroten I solved the problem in May and my weather station works well now:)