Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib2,csv,json,time
- class Struct:
- def __init__(self, **entries):
- self.__dict__.update(entries)
- class GetET:
- def __init__(self,station):
- self.station=station
- self.ET=Struct(**self.getET())
- def getET(self):
- year = str(time.localtime()[0])[2:]
- url = 'http://www.usbr.gov/pn/agrimet/chart/'+self.station+year+'et.txt'
- response = urllib2.urlopen(url)
- html = response.read()
- dateindex=html.index("DATE")
- items=html[dateindex::].split('\n')[0].split(' ')[:-1]
- items = [value for value in items if value != '']
- data = html[dateindex:].split('\n')[2:]
- data = [value for value in data if value != '']
- yestET = data[len(data)-2].split(' ')[1::]
- yestET = [value for value in yestET if value != '']
- eT={}
- for i,info in enumerate(yestET):
- eT[items[i]]=info
- return eT
Advertisement
Add Comment
Please, Sign In to add comment