Created
September 17, 2015 06:27
-
-
Save jampola/fc847b0d60d382040696 to your computer and use it in GitHub Desktop.
Simple yahoo weather
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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