Skip to content

Instantly share code, notes, and snippets.

@jampola
Created September 17, 2015 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jampola/fc847b0d60d382040696 to your computer and use it in GitHub Desktop.
Save jampola/fc847b0d60d382040696 to your computer and use it in GitHub Desktop.
Simple yahoo weather
# -*- coding: utf-8 -*-
#!/usr/bin/python
import urllib2
import json
import time
import os
import sys
import pprint
class weatherData:
def __init__(self,woeid):
self.user_woeid = woeid
def get(self,woeid,unit_format):
q='SELECT%20*%20FROM%20weather.forecast%20WHERE%20woeid="{}"%20and%20u="{}"&format=json'.format(woeid,unit_format)
weather_req_url = 'http://query.yahooapis.com/v1/public/yql?q={}'.format(q)
request = urllib2.urlopen(weather_req_url).read()
self.data = json.loads(request)
pprint.pprint(self.data)
def run(self):
return self.get(self.user_woeid,'c')
if __name__ == '__main__':
app = weatherData('1226059')
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment