I have a licence from Melbourne Water to pump water from the Yarra River. Water pumped from the river is stored in a large concrete tank (20,000 liters), and used for toilet flushing, watering the garden and as a source of water for fire fighting.
For environmental reasons, pumping from the river is restricted during periods of low flow. Melbourne water publishes flow and pumping restriction data on their website, so I can check if restrictions apply before starting the pump to top up the tank. I hacked together a quick python script to get the information I need, so I can display the information on my computer’s desktop using conky.
#!/usr/bin/env python #Python script to get current pumping restrictions for Upper Yarra River. import mechanize import HTMLParser from BeautifulSoup import BeautifulSoup BASE_URL = "http://www.melbournewater.com.au/content/rivers_and_creeks/waterway_diverters/yarra_upper.asp" br = mechanize.Browser() data = br.open(BASE_URL).get_data() soup = BeautifulSoup(data) table=soup.find("table",title="Table showing current waterway diversion status") for row in table.findAll('tr')[1:]: col = row.findAll('td') restrict = col ban = col.string flow = col.string avflow = col.string date = col.string #Function to strip html tags from table cells (allows for episodic coloring/bolding of cell contents when bans apply!) def stripper(data): data = str(data) count = data.count('<') while count: start = data.find('<') end = data.find('>') rem = data[start:end+1] data = data.replace(rem,'',1) count-=1 out = data return out #apply the stripper function to current restriction and ban statuses restrict = stripper(restrict) ban = stripper(ban) print 'Restricted? %s Banned? %s' % (restrict, ban) print 'Flow: %s ML/d AvFlow: %s ML/d' % (flow, avflow)