Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

HTTP Error 502: Connection refused #5

Closed
Hisoka87 opened this issue Apr 27, 2016 · 9 comments
Closed

HTTP Error 502: Connection refused #5

Hisoka87 opened this issue Apr 27, 2016 · 9 comments

Comments

@Hisoka87
Copy link

Hisoka87 commented Apr 27, 2016

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.

@Abolisher
Copy link

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.

@drecrumbs
Copy link

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.

@Hisoka87
Copy link
Author

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

@Abolisher
Copy link

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

@Abolisher
Copy link

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']

@Hisoka87
Copy link
Author

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

@athallas
Copy link

@tsroten any updates?

@tsroten
Copy link
Owner

tsroten commented Aug 12, 2016

@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 tsroten closed this as completed Aug 12, 2016
@Esse87
Copy link

Esse87 commented Aug 12, 2016

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants