Jul-25-2017, 07:42 AM
Attempt:
#note: the url is actually there in the code, but it was preventing me from posting this url = 'freegeoip' try: with closing(urlopen(url)) as response: location = json.loads(response.read()) loc_c = location['city'] loc_s = location['region_name'] except: print('step 1 failed') client = yweather.Client() wid = client.fetch_woeid('loc_c, loc_s') print(wid) print('steps 1 and 2 finished') print('step 3 started') loc_weather = client.fetch_weather(wid) loc_weather["condition"]["text"] loc_weather["condition"]["temp"] print('step 3 finished')Also while I was typing this, a new traceback popped up:
Error:Traceback (most recent call last):
File "weather.py", line 21, in <module>
loc_weather = client.fetch_weather(wid)
File "/usr/local/lib/python2.7/dist-packages/yweather.py", line 180, in fetch_weather
rss = self._fetch_xml(url)
File "/usr/local/lib/python2.7/dist-packages/yweather.py", line 344, in _fetch_xml
with contextlib.closing(urlopen(url)) as f:
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 429, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 447, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1228, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1198, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 22] Invalid argument>